瀏覽代碼

清除同终端过期号牌,尽量使用地感获得的号牌

yct 6 年之前
父節點
當前提交
e2b61ae8aa

+ 1 - 1
PLCLinker/centralController/FormCentralController.cs

@@ -386,7 +386,7 @@ namespace centralController
                                         //Console.WriteLine("text is :" + space.Text+", index:"+index);
                                         if (idPssMap.ContainsKey(index))
                                         {
-                                            Console.WriteLine("index:" + index+", status:"+ idPssMap[index].spaceStatus);
+                                            //Console.WriteLine("index:" + index+", status:"+ idPssMap[index].spaceStatus);
                                             space.BackColor = GetPSColor(idPssMap[index].spaceStatus);
                                         }
                                         else if(result)

+ 16 - 1
PLCLinker/centralController/NumMachine/NumMachine.cs

@@ -920,8 +920,24 @@ namespace NumMachine
         public string GetLicensePlate(int id)
         {
             string license = "";
+            NumberMachineNode node = null;
             //Task.Factory.StartNew(() =>
             //{
+            //清除同终端号过期号牌
+            lock (LicBuffer)
+            {
+                for (int i = 0; i < LicBuffer.Count; i++)
+                {
+                    node = LicBuffer.Dequeue();
+                    if (node != null)
+                    {
+                        if (node.id != id)
+                        {
+                            LicBuffer.Enqueue(node);
+                        }
+                    }
+                }
+            }
             //将相应计数器归零,启动号牌记录
             lock (idCountMap)
             {
@@ -947,7 +963,6 @@ namespace NumMachine
                 }
             }
 
-            NumberMachineNode node = null;
             int timeLimit = FILTERINGNUMBER + 2;
             while (node == null && timeLimit-- > 0)
             {

+ 63 - 57
PLCLinker/centralController/Terminal/Terminal.cs

@@ -289,11 +289,11 @@ namespace Terminal
         /// <param name="id"></param>
         private static void ClearTerminal(int id, bool removeReceipt)
         {
-            for(int i = 0; i < terminalInfo.Count; i++)
+            for (int i = 0; i < terminalInfo.Count; i++)
             {
-                if(terminalInfo[i].terminalID == id)
+                if (terminalInfo[i].terminalID == id)
                 {
-                    Log.WriteLog(LogType.process, LogFile.WARNING, "即将删除终端" + id + "数据:" +terminalInfo[i].ToString());
+                    Log.WriteLog(LogType.process, LogFile.WARNING, "即将删除终端" + id + "数据:" + terminalInfo[i].ToString());
                 }
             }
             TerminalStru tsFromCentral = new TerminalStru
@@ -420,7 +420,7 @@ namespace Terminal
                     Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
                     status = 1;
                     Log.WriteLog(LogType.process, LogFile.ERROR, "网络异常,无法验证号牌");
-                }  
+                }
             }
         }
         /// <summary>
@@ -500,25 +500,31 @@ namespace Terminal
                     if (term.terminalStatus == (short)1)
                     {
                         string license = "";
+                        license = Monitor.Monitor.numMachineLinker.GetLicensePlate(term.terminalID);
                         //判断之前是否已拍摄号牌
                         if (!idLicMap.ContainsKey(term.terminalID))
                         {
-                            license = Monitor.Monitor.numMachineLinker.GetLicensePlate(term.terminalID);
-                            Monitor.Monitor.SetNotification("启动" + term.terminalID + "号号牌机,号牌:" + license, parkMonitor.model.TextColor.Info);
+                            Monitor.Monitor.SetNotification("启动" + term.terminalID + "号号牌机,号牌:[" + license + "]", parkMonitor.model.TextColor.Info);
                         }
                         else
                         {
-                            idLicMap.TryGetValue(term.terminalID, out license);
+                            string lic = "";
+                            idLicMap.TryGetValue(term.terminalID, out lic);
+                            if (license != lic && lic != "")
+                            {
+                                Monitor.Monitor.SetNotification("与地感获得号牌[" + lic + "]不一致,启动" + term.terminalID + "号号牌机,号牌:[" + license + "],最终使用[" + lic + "]停车", parkMonitor.model.TextColor.Warning);
+                                license = lic;
+                            }
                         }
 
                         //记录或更新当前号牌,若无则填入默认号牌
                         string currentLic = "";
                         lock (idLicMap)
                         {
-                            if(license == "")
+                            if (license == "")
                             {
                                 currentLic = Monitor.Monitor.defaultLic;
-                                Monitor.Monitor.SetNotification("使用默认号牌,凭证号"+ term.receiptNum, parkMonitor.model.TextColor.Error);
+                                Monitor.Monitor.SetNotification("使用默认号牌,凭证号" + term.receiptNum, parkMonitor.model.TextColor.Error);
                                 Log.WriteLog(LogType.process, LogFile.ERROR, term.terminalID + "号号牌机未获得号牌,使用默认号牌,凭证号:" + term.receiptNum);
                             }
                             else
@@ -581,59 +587,59 @@ namespace Terminal
                         //}
                         //else
                         //{
-                            TerminalStru ts = new TerminalStru
+                        TerminalStru ts = new TerminalStru
+                        {
+                            terminalID = (short)term.terminalID,
+                            paymentStatus = -1,
+                            parkingFee = -1,
+                            userType = -1
+                        };
+                        //注册用户
+                        if (term.btnStatus == (short)2 || term.btnStatus == (short)3)
+                        {
+                            int userID = term.licenseCodeA;
+                            string userLicense = GetLicenseFromTerm(term);
+                            //注册用户缺ID信息,转为普通用户停车,终端将限制该情况发生
+                            if (userID == 0)
                             {
-                                terminalID = (short)term.terminalID,
-                                paymentStatus = -1,
-                                parkingFee = -1,
-                                userType = -1
-                            };
-                            //注册用户
-                            if (term.btnStatus == (short)2 || term.btnStatus == (short)3)
+                                term.btnStatus = 1;
+                            }
+                            else
                             {
-                                int userID = term.licenseCodeA;
-                                string userLicense = GetLicenseFromTerm(term);
-                                //注册用户缺ID信息,转为普通用户停车,终端将限制该情况发生
-                                if (userID == 0)
+                                //与云端数据比对,比对失败转普通用户停车
+                                ValidateUserInfo(ts, userID, userLicense, out numReceivedStatus);
+                                if (numReceivedStatus == 2)
                                 {
                                     term.btnStatus = 1;
+                                    //idLicMap.Remove(term.terminalID);
                                 }
-                                else
-                                {
-                                    //与云端数据比对,比对失败转普通用户停车
-                                    ValidateUserInfo(ts, userID, userLicense, out numReceivedStatus);
-                                    if (numReceivedStatus == 2)
-                                    {
-                                        term.btnStatus = 1;
-                                        //idLicMap.Remove(term.terminalID);
-                                    }
-                                }
-                            }
-                            //非注册用户
-                            if (term.btnStatus == (short)1 || term.btnStatus == (short)4)
-                            {
-                                numReceivedStatus = 1;
-                                ts.licVerification = 1;
-                                Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
                             }
-                            if (term.btnStatus == (short)0)
-                            {
-                                ts.licVerification = 1;
-                                Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
-                                Log.WriteLog(LogType.process,LogFile.ERROR,"空按钮状态拍号牌");
-                            }
-                            //无论是否注册,皆告知PLC,已获取号牌或比对异常、终止流程
-                            MainBlockStru mbst = new MainBlockStru
-                            {
-                                centralHearbeat = -1,
-                                bookFetchCmd = -1,
-                                bookParkCmd = -1,
-                                processCompleted = (short)-1,
-                                licenseReceived = (short)numReceivedStatus
-                            };
-                            Monitor.Monitor.PLC.WriteToPLC(mbst, PLCDataType.central);
-                            //号牌获取结果被清零才跳出
-                            Monitor.Monitor.SetNotification("已写入号牌获取结果"+ numReceivedStatus + ",等待号牌机启动指令清零", parkMonitor.model.TextColor.Info);
+                        }
+                        //非注册用户
+                        if (term.btnStatus == (short)1 || term.btnStatus == (short)4)
+                        {
+                            numReceivedStatus = 1;
+                            ts.licVerification = 1;
+                            Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
+                        }
+                        if (term.btnStatus == (short)0)
+                        {
+                            ts.licVerification = 1;
+                            Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
+                            Log.WriteLog(LogType.process, LogFile.ERROR, "空按钮状态拍号牌");
+                        }
+                        //无论是否注册,皆告知PLC,已获取号牌或比对异常、终止流程
+                        MainBlockStru mbst = new MainBlockStru
+                        {
+                            centralHearbeat = -1,
+                            bookFetchCmd = -1,
+                            bookParkCmd = -1,
+                            processCompleted = (short)-1,
+                            licenseReceived = (short)numReceivedStatus
+                        };
+                        Monitor.Monitor.PLC.WriteToPLC(mbst, PLCDataType.central);
+                        //号牌获取结果被清零才跳出
+                        Monitor.Monitor.SetNotification("已写入号牌获取结果" + numReceivedStatus + ",等待号牌机启动指令清零", parkMonitor.model.TextColor.Info);
                         //}
                         int countdown = 10;
                         while (countdown-- > 0)
@@ -729,7 +735,7 @@ namespace Terminal
                     {
                         parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
                             "values ('" + term.licenseCodeA + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + receipt + "',NULL);";
-                        Monitor.Monitor.SetNotification("用户"+ term.licenseCodeA + "插入停车记录", parkMonitor.model.TextColor.Info);
+                        Monitor.Monitor.SetNotification("用户" + term.licenseCodeA + "插入停车记录", parkMonitor.model.TextColor.Info);
                         Log.WriteLog(LogType.process, LogFile.INFO, "用户" + term.licenseCodeA + "插入停车记录," + license + "停在" + parkingSpaceID + ",凭证号:" + receipt);
                     }
                     else