Jelajahi Sumber

数据库操作协调

yc_t 7 tahun lalu
induk
melakukan
c4678428a0

+ 1 - 1
parkMonitor/App.config

@@ -16,7 +16,7 @@
   </Equipments>
   <appSettings>
     <!--数据库连接配置文件-->
-    <add key="SqlConnectionLocation" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;pwd=jingwang1995;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />
+    <add key="SqlConnectionLocation" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;pwd=yct;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />
     <!--<add key="SqlConnectionStr" value="Data Source=52.77.33.102;port=3306;uid=Ubuntu1;pooling=true;pwd=12345678;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />-->
 <add key="SqlConnectionStr" value="Data Source=59.175.148.85;port=3306;uid=root;pooling=true;pwd=x5;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" /> 
 <!--日志写入地址配置文件-->

+ 2 - 2
parkMonitor/DB/DBOperation.cs

@@ -179,7 +179,7 @@ namespace parkMonitor.DB
                         int parkingSpaceID = reader.GetInt32("parkingSpaceID");
                         //float parkingSpaceWeight = reader.GetFloat("parkingSpaceWeight");
                         //int parkingSpaceStatement = reader.GetInt32("parkingSpaceState");
-                        int garageID = reader.GetInt32("garageID");
+                        //int garageID = reader.GetInt32("garageID");
                         int parkingSpaceX = reader.GetInt32("parkingSpaceX");
                         int parkingSpaceY = reader.GetInt32("parkingSpaceY");
                         int parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
@@ -539,7 +539,7 @@ namespace parkMonitor.DB
             // List<Vehicle> lVehicle = new List<Vehicle>();
             Vehicle v = new Vehicle();
             MySqlDataReader reader = null;
-            string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "'";
+            string sql = "select * from vehicle where numberPlate = '" + numberPlate + "'";
             con = oper.getConn();
             try
             {

+ 47 - 1
parkMonitor/DBLocation/DBLocation.cs

@@ -508,7 +508,7 @@ namespace parkMonitor.DBLocation
                         int parkingSpaceID = reader.GetInt32("parkingSpaceID");
                         //float parkingSpaceWeight = reader.GetFloat("parkingSpaceWeight");
                         //int parkingSpaceStatement = reader.GetInt32("parkingSpaceState");
-                        int garageID = reader.GetInt32("garageID");
+                        //int garageID = reader.GetInt32("garageID");
                         int parkingSpaceX = reader.GetInt32("parkingSpaceX");
                         int parkingSpaceY = reader.GetInt32("parkingSpaceY");
                         int parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
@@ -594,5 +594,51 @@ namespace parkMonitor.DBLocation
             return v;
         }
 
+        //根据车位id获得x,y,z
+        public Fetching_Space GetFetchingSpace(int parkingSpaceID)
+        {
+            Fetching_Space fs = new Fetching_Space();
+            MySqlDataReader reader = null;
+            string sql = "select * from parkingspace where parkingSpaceID = '" + parkingSpaceID + " '";
+            con = oper.getConn();
+            try
+            {
+                con.Open();
+                cmd = oper.getComm(sql, con);
+                reader = oper.getResultSet(cmd);
+                while (reader.Read())
+                {
+                    if (reader.HasRows)
+                    {
+                        int parkingSpaceX = reader.GetInt32("parkingSpaceX");
+                        int parkingSpaceY = reader.GetInt32("parkingSpaceY");
+                        int parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
+                        fs.parkingSpaceX = parkingSpaceX;
+                        fs.parkingSpaceY = parkingSpaceY;
+                        fs.parkingSpaceZ = parkingSpaceZ;
+                    }
+                }
+                if (reader != null)
+                {
+                    reader.Close();
+                    reader.Dispose();
+                }
+                if (cmd != null)
+                {
+                    cmd.Dispose();
+                }
+                if (con != null)
+                {
+                    con.Close();
+                    con.Dispose();
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.ToString());
+            }
+            return fs;
+        }
+
     }
 }

+ 11 - 3
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -179,11 +179,11 @@ namespace parkMonitor.server.CoreThread
             {
                 if (!queueCmd.manual)
                 {
-                    ppp = aps.MallocParkingSpace(cEntrance, oper);//自动
+                    ppp = aps.MallocParkingSpace(cEntrance, oper, queueCmd);//自动
                 }
                 else
                 {
-                    ppp = aps.MallocParkingSpace(cEntrance, locationOper);//手动
+                    ppp = aps.MallocParkingSpace(cEntrance, locationOper, queueCmd);//手动
                 }
                 if (ppp != null)
                 {
@@ -533,7 +533,15 @@ namespace parkMonitor.server.CoreThread
             int garageID = vehiclelist.garageID;
             int frontwheelbase = vehiclelist.frontwheelbase;
             int rearwheelbase = vehiclelist.rearwheelbase;
-            Fetching_Space fslist = oper.GetFetchingSpace(parkingSpaceID);
+            Fetching_Space fslist = null;
+            if (queueCmd.manual)
+            {
+                fslist = locationOper.GetFetchingSpace(parkingSpaceID);
+            }
+            else
+            {
+                fslist = oper.GetFetchingSpace(parkingSpaceID);
+            }
             int parkingSpaceX = fslist.parkingSpaceX;
             int parkingSpaceY = fslist.parkingSpaceY;
             int parkingSpaceZ = fslist.parkingSpaceZ;

+ 1 - 1
parkMonitor/server/CoreThread/CoreThreadTest2.cs

@@ -86,7 +86,7 @@ namespace parkMonitor.server.CoreThread
             AbstractCmd.isClosing = true;//停止运行中指令
         }
 
-        public void BeginWorking() 
+        public void BeginWorking()
         {
             while (true)
             {

+ 12 - 12
parkMonitor/server/NumMachine/NumMachine.cs

@@ -630,18 +630,18 @@ namespace parkMonitor.server
                 Run();
             });
 
-            Task imgTest = Task.Factory.StartNew(() =>
-            {
-                while (!isClosing)
-                {
-                    Command cmd = new Command
-                    {
-                        id = 1
-                    };
-                    SetMessage(cmd);
-                    Thread.Sleep(5000);
-                }
-            });
+            //Task imgTest = Task.Factory.StartNew(() =>
+            //{
+            //    while (!isClosing)
+            //    {
+            //        Command cmd = new Command
+            //        {
+            //            id = 1
+            //        };
+            //        SetMessage(cmd);
+            //        Thread.Sleep(5000);
+            //    }
+            //});
 
         }