diff --git a/resources/wwwroot/js/profile.js b/resources/wwwroot/js/profile.js index 518cb7f..554bd2c 100644 --- a/resources/wwwroot/js/profile.js +++ b/resources/wwwroot/js/profile.js @@ -1,2 +1,7 @@ $(document).ready(function() { + $("#firstname").value("hhh"); + + $.post('/senddata/checkloginstate', 'action=getfirstname', function (data) { + console.log(data); + }, 'json'); }); diff --git a/resources/wwwroot/profile.html b/resources/wwwroot/profile.html index 9a3ad9e..d17be5d 100644 --- a/resources/wwwroot/profile.html +++ b/resources/wwwroot/profile.html @@ -67,8 +67,8 @@
- -
+ +
diff --git a/src/com/wasteinformationserver/main.java b/src/com/wasteinformationserver/main.java index 6bcbc07..e5e5e8a 100644 --- a/src/com/wasteinformationserver/main.java +++ b/src/com/wasteinformationserver/main.java @@ -9,7 +9,7 @@ public class main { - Runtime.getRuntime().addShutdownHook(new Thread(() -> { + /* Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { Thread.sleep(200); Log.warning("Shutting down ..."); @@ -23,7 +23,7 @@ public class main { Thread mythread = new Thread(() -> new Webserver().startserver()); mythread.start(); - Log.message("thread started"); + Log.message("thread started");*/ mqtt m = new mqtt(); m.notifymessage(); diff --git a/src/com/wasteinformationserver/mqtt/mqtt.java b/src/com/wasteinformationserver/mqtt/mqtt.java index fe0f65a..742a634 100644 --- a/src/com/wasteinformationserver/mqtt/mqtt.java +++ b/src/com/wasteinformationserver/mqtt/mqtt.java @@ -22,53 +22,30 @@ public class mqtt { public void notifymessage() { - - GregorianCalendar now = new GregorianCalendar(); - DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG); - String date = df.format(now.getTime()); - - Log.debug(date); - - String[] parts = date.split(" "); - String temp2=parts[0]; - Log.debug(temp2); - String[] partstwo=temp2.split("\\."); - String newDate="20"+partstwo[2]+"-"+partstwo[1]+"-"+partstwo[0]; - - - mqttreceiver mr = new mqttreceiver(); - -// Log.debug(message); - mr.addMessageReceivedListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String temp = e.getActionCommand(); + System.out.println(temp); String[] split = temp.split(","); - String message = "SELECT*FROM place WHERE Ort='" + split[0] + "' AND Abfallart='" + split[1] + "' AND Zone='" + split[2] + "' AND ABholtag='"+newDate+"'"; - - getDatabasedata(message); + getDatabasedata("SELECT pickupdates.pickupdate FROM pickupdates WHERE pickupdates.citywastezoneid=(SELECT cities.zone FROM cities WHERE cities.name='" + split[1] + "' AND cities.wastetype='" + split[2] + "' AND cities.zone=" + split[3] + ")",split[2], Integer.parseInt(split[0])); } }); - mr.getmessage(); - } - public void getDatabasedata(String message) { + public void getDatabasedata(String message,String wastetyp, int clientidentify) { String temp; - Log.debug(message); JDCB Database = new JDCB("placeuser", "eaL956R6yFItQVBl", "wasteinformation"); ResultSet result = Database.executeQuery(message); try { while (result.next()) { - String temptime = String.valueOf(result.getString("Abholtag")); - String tempabfallart = String.valueOf(result.getString("Abfallart")); + String temptime = String.valueOf(result.getString("pickupdate")); GregorianCalendar now = new GregorianCalendar(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG); @@ -91,17 +68,19 @@ public class mqtt { } else { abholtag = 0; } - temp = tempabfallart + "," + abholtag; + temp = clientidentify+","+ wastetyp + "," + abholtag; System.out.println(temp); if (temp != null) { transmitmessageAbfallart(temp); + notifymessage(); } else { Log.debug("NO Connection"); } } } catch (SQLException e) { + System.out.println("Exception"); e.printStackTrace(); } @@ -109,6 +88,7 @@ public class mqtt { } + private void transmitmessageAbfallart(String temp) { mqtttransmitter mt = new mqtttransmitter(); diff --git a/src/com/wasteinformationserver/mqtt/mqttreceiver.java b/src/com/wasteinformationserver/mqtt/mqttreceiver.java index 4533d6e..a745d63 100644 --- a/src/com/wasteinformationserver/mqtt/mqttreceiver.java +++ b/src/com/wasteinformationserver/mqtt/mqttreceiver.java @@ -23,8 +23,6 @@ public class mqttreceiver { public String getmessage() { - String temp; - try { client = new MqttClient("tcp://192.168.65.15:1883", "JavaSample"); client.connect();