asdf
This commit is contained in:
parent
23bffc4c6e
commit
e4f9d88cda
@ -4,7 +4,7 @@
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -33,8 +33,8 @@ public class main {
|
||||
Log.message("initial login to db");
|
||||
new Thread(() -> {
|
||||
try {
|
||||
JDCB.init("ingproject", "Kb9Dxklumt76ieq6", "ingproject", "db.power4future.at", 3306);
|
||||
//JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
|
||||
//JDCB.init("users", "admin0", "wasteinformation", "192.168.65.15", 1883);
|
||||
JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
Log.error("no connection to db");
|
||||
|
@ -43,7 +43,9 @@ public class mqtt {
|
||||
String temp = e.getActionCommand();
|
||||
|
||||
String[] split = temp.split(",");
|
||||
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]));
|
||||
String wastetyp = getTyp(Integer.parseInt(split[2]));
|
||||
System.out.println(wastetyp);
|
||||
getDatabasedata("SELECT pickupdates.pickupdate FROM pickupdates WHERE pickupdates.citywastezoneid=(SELECT cities.zone FROM cities WHERE cities.name='" + split[1] + "' AND cities.wastetype='" + wastetyp + "' AND cities.zone=" + split[3] + ")", wastetyp, Integer.parseInt(split[0]));
|
||||
}
|
||||
});
|
||||
mr.getmessage();
|
||||
@ -51,20 +53,21 @@ public class mqtt {
|
||||
|
||||
public void getDatabasedata(String message, String wastetyp, int clientidentify) {
|
||||
|
||||
System.out.println("message");
|
||||
Log.debug(message);
|
||||
Log.debug(wastetyp);
|
||||
Log.debug(clientidentify);
|
||||
JDCB Database = null;
|
||||
try {
|
||||
Database = JDCB.getInstance();
|
||||
} catch (IOException e) {
|
||||
Log.error("No Connection to the databank");
|
||||
}
|
||||
int wastenumber = getIntTyp(wastetyp);
|
||||
System.out.println("wastenumber" + wastenumber);
|
||||
//new JDCB("placeuser", "eaL956R6yFItQVBl", "wasteinformation");
|
||||
ResultSet result = Database.executeQuery(message);
|
||||
try {
|
||||
if (!result.isBeforeFirst()) {
|
||||
int abholtag = 0;
|
||||
transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag);
|
||||
} else {
|
||||
while (result.next()) {
|
||||
String temptime = String.valueOf(result.getString("pickupdate"));
|
||||
|
||||
@ -81,20 +84,18 @@ public class mqtt {
|
||||
|
||||
|
||||
int abholtag;
|
||||
if (partstwo[0].contains(newDate) || partstwo[0].contains(Datetomorrow)) {
|
||||
if (partstwo[0].equals(newDate) || partstwo[0].equals(Datetomorrow)) {
|
||||
abholtag = 1;
|
||||
transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag);
|
||||
transmitmessageAbfallart(clientidentify + "," + wastenumber + "," + abholtag);
|
||||
} else {
|
||||
abholtag = 0;
|
||||
transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag);
|
||||
transmitmessageAbfallart(clientidentify + "," + wastenumber + "," + abholtag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.error("No data from database");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -120,4 +121,31 @@ public class mqtt {
|
||||
String newDate = split[2] + "." + split[1] + "." + split[0];
|
||||
return newDate;
|
||||
}
|
||||
|
||||
private String getTyp(int number) {
|
||||
if (number == 1) {
|
||||
return "Plastic";
|
||||
} else if (number == 2) {
|
||||
return "Metal";
|
||||
} else if (number == 3) {
|
||||
return "Residual waste";
|
||||
} else if (number == 4) {
|
||||
return "Biowaste";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getIntTyp(String temp) {
|
||||
int number = 0;
|
||||
if (temp.equals("Plastic")) {
|
||||
number = 1;
|
||||
} else if (temp.equals("Metal")) {
|
||||
number = 2;
|
||||
} else if (temp.equals("Residual waste")) {
|
||||
number = 3;
|
||||
} else if (temp.equals("Biowaste")) {
|
||||
number = 4;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user