diff --git a/src/main/java/com/application/DB/Constants.java b/src/main/java/com/application/DB/Constants.java index 93266724946d3b1f6c7d9e82493976efc2cba56f..4ac1ab30e3ba51ccef7dc581735d16bb7fe57b9a 100644 --- a/src/main/java/com/application/DB/Constants.java +++ b/src/main/java/com/application/DB/Constants.java @@ -2,8 +2,6 @@ package com.application.DB; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Calendar; -import java.util.Date; /** * This class contains constants to be used related to database activities @@ -20,10 +18,17 @@ public final class Constants { // Today's date public static final String TODAYS_DATE = format.format(LocalDateTime.now()); + // User inputs + public static final String TREE_SPECIES = ""; + public static final String WIDTH_DIMENTION = ""; + public static final String HEIGHT_DIMENTION = ""; + public static final String SAWSET = ""; + public static final int MOISTURE_GOAL = 0; + // Database ID/name public static final String PROJECT_ID = "sf-drying-optimization"; - + /* // Location Valasen(124) // Project settings public static final int LOCATION_ID = 124; @@ -40,15 +45,12 @@ public final class Constants { // Winccsensordata public static final String KWH_NAME = "VariantValue"; + public static final String TIMESTAMP_NAME = "Timestamp"; + public static final String VALUE_ID_NAME = "ValueID"; public static final int VALUE_ID = 51; +*/ - - - - - -/* // Location Arjang(174) // Project settings public static final int LOCATION_ID = 174; @@ -63,11 +65,13 @@ public final class Constants { public static final String KILIN_NAME = "KilinId"; public static final int KILIN_ID = 16; - // Winccsensordata + // Swappconsensordata public static final String KWH_NAME = "RealValue"; + public static final String TIMESTAMP_NAME = "Timestamp"; + public static final String VALUE_ID_NAME = "ValueID"; public static final int VALUE_ID = 19; - */ + } diff --git a/src/main/java/com/application/DB/DB.java b/src/main/java/com/application/DB/DB.java index a5336258aac353ac8cc5c9ad218a1e2766cc16da..44df77c7cf62785314c374c4fb28e5c3cc39e958 100644 --- a/src/main/java/com/application/DB/DB.java +++ b/src/main/java/com/application/DB/DB.java @@ -168,12 +168,12 @@ public class DB { // Preparing a query statement // Query statement 124 ValÄsen - final String sqlStatement = "SELECT `TimeStamp`, `"+KWH_NAME+"` " + + final String sqlStatement = "SELECT `" + TIMESTAMP_NAME + "`, `"+KWH_NAME+"` " + "FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_KWH + "` " + - "WHERE TimeStamp BETWEEN " + '"'+ entry.getKey() + '"' + + "WHERE " + TIMESTAMP_NAME + " BETWEEN " + '"'+ entry.getKey() + '"' + " AND " + '"' + entry.getValue() + '"' + - " AND ValueID = " + VALUE_ID + " " + - " ORDER BY TimeStamp ASC"; + " AND " + VALUE_ID_NAME + " = " + VALUE_ID + " " + + " ORDER BY " + TIMESTAMP_NAME + " ASC"; @@ -209,7 +209,7 @@ public class DB { int variantValue = row.get(""+KWH_NAME+"").getNumericValue().intValue()-baseline; //-baseline // Retrieving the wanted data - long timeStamp = row.get("TimeStamp").getTimestampValue() / 1000; + long timeStamp = row.get(""+TIMESTAMP_NAME+"").getTimestampValue() / 1000; // Riktig format, men i string String formatedTimeStamp = getDateFormat().format(timeStamp); @@ -369,20 +369,8 @@ public class DB { formatedUtTidTork = splitValue[0] + " " + splitValue[1]; } - System.out.println("Inn formated: "+formatedInTidTork); - System.out.println("Ut formated: "+formatedUtTidTork+"\n"); - - /* - // CalculatedStop: - // DryingCompleted: - if(!row.get("CalculatedStop").isNull()){ - long utTidTorkLong = row.get("CalculatedStop").getTimestampValue()/1000; - // Formating the data from long to a string in the correct date format - formatedUtTidTork = getDateFormat().format(utTidTorkLong); - } else { - formatedUtTidTork = ""; - } - */ + //System.out.println("Inn formated: "+formatedInTidTork); + //System.out.println("Ut formated: "+formatedUtTidTork+"\n"); // Checks if intidtork or outtidtork is empty, if so they are ignored and not added to the list if (!formatedInTidTork.isEmpty() && !formatedUtTidTork.isEmpty()){ @@ -391,7 +379,7 @@ public class DB { } //System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork); } - System.out.printf("Size of dates: %s\n", dates.size()); + System.out.printf("Size of dates: %s\n\n", dates.size()); // Returns a treemap that sorts the dates incrementally return new TreeMap<>(dates); diff --git a/target/classes/com/application/DB/Constants.class b/target/classes/com/application/DB/Constants.class index c682eb0f42ee8e24b82c8dc46fc7e8e06d2425f1..14407c07cc72e24209bd8991a9fb98f2be5d84fb 100644 Binary files a/target/classes/com/application/DB/Constants.class and b/target/classes/com/application/DB/Constants.class differ diff --git a/target/classes/com/application/DB/DB.class b/target/classes/com/application/DB/DB.class index d01f067c3c3db55edf5e5ab9b325a53bacff7aaa..930d3bfeb7876cbc25bd0d07360ce2a8b11756f1 100644 Binary files a/target/classes/com/application/DB/DB.class and b/target/classes/com/application/DB/DB.class differ