multiple replies on device request with more than one city provided
This commit is contained in:
		| @@ -52,14 +52,22 @@ public class MqttService { | |||||||
|                             //existing device |                             //existing device | ||||||
|                             res.first(); |                             res.first(); | ||||||
|  |  | ||||||
|                             // TODO: 23.01.20  --> check device_city db and foreach all cities  |                             ResultSet devicecities = db.executeQuery("SELECT * from device_city WHERE DeviceID='" + deviceid + "'"); | ||||||
|                             int cityid = res.getInt("CityID"); |                             devicecities.last(); | ||||||
|                             if (cityid == -1) { |                             if (devicecities.getRow() == 0) { | ||||||
|                                 //device not configured yet |                                 //not configured | ||||||
|                                 tramsmitMessage(deviceid + ",-1"); |                                 tramsmitMessage(deviceid + ",-1"); | ||||||
|                             } else { |                             } else { | ||||||
|  |                                 devicecities.first(); | ||||||
|  |                                 devicecities.previous(); | ||||||
|  |                                 // TODO: 23.01.20 Test this stuff  | ||||||
|  |                                 while (devicecities.next()) { | ||||||
|  |                                     int cityid = devicecities.getInt("CityID"); | ||||||
|                                     checkDatabase(cityid, Integer.parseInt(deviceid)); |                                     checkDatabase(cityid, Integer.parseInt(deviceid)); | ||||||
|                                 } |                                 } | ||||||
|  |                             } | ||||||
|  |  | ||||||
|  |  | ||||||
|                         } else { |                         } else { | ||||||
|                             //new device |                             //new device | ||||||
|                             db.executeUpdate("INSERT INTO devices (DeviceID) VALUES (" + deviceid + ")"); |                             db.executeUpdate("INSERT INTO devices (DeviceID) VALUES (" + deviceid + ")"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user