diff --git a/src/main/java/com/application/DB/DB.java b/src/main/java/com/application/DB/DB.java index 3cb57f0b5c2bf8e0223117a4ad3ae816f4769e29..02348eb6043a6d79fc78e08e166b14862aaf6181 100644 --- a/src/main/java/com/application/DB/DB.java +++ b/src/main/java/com/application/DB/DB.java @@ -179,7 +179,7 @@ public class DB { "SELECT Timestamp, RealValue FROM `sf-drying-optimization.174.int_sd_swappconsensordata` " + "WHERE TimeStamp BETWEEN " + '"'+ entry.getKey() + '"' + " AND " + '"' + entry.getValue() + '"' + - "AND ValueID = 14 " + + "AND ValueID = 19 " + "AND RealValue <> 0 " + "ORDER BY TimeStamp ASC"; @@ -201,18 +201,23 @@ public class DB { //System.out.println("baseline: "+baseline); // kWh value - int variantValue = row.get("VariantValue").getNumericValue().intValue(); //-baseline + int variantValue = row.get("VariantValue").getNumericValue().intValue()-baseline; //-baseline // Retrieving the wanted data long timeStamp = row.get("TimeStamp").getTimestampValue() / 1000; // Riktig format, men i string String formatedTimeStamp = getDateFormat().format(timeStamp); +/* // Checks for negative values and unresonable large values if(variantValue > 0){ //&& variantValue < 5000000){ // Adding the data to a list in order to sort through later data.put(formatedTimeStamp, variantValue); } + + */ + data.put(formatedTimeStamp, variantValue); + //System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\t\t\tBaseline: %s\n",formatedTimeStamp,variantValue,baseline); // Checks if the data is empty } @@ -228,7 +233,7 @@ public class DB { System.out.println("\nFinal results size: "+finalResults.size()); - // Defining a treemap to sort through the data + // Defining a treemap to sort the data incrementally NavigableMap<Integer, Map> sortedFinalResults = new TreeMap<>(finalResults); @@ -250,7 +255,7 @@ public class DB { * A possible extention of this function could be to limit the number of dring periodes. * This could be done with counting the number of entries in * - * @return A hashmap containing the correct intidtork and outtidtork dates + * @return Returns a treemap that sorts the Start- and End time for each drying period incrementally * @throws Exception Throws exception if an error occurs */ private static Map<String, String> getZeroPointDate() throws Exception{ @@ -335,7 +340,9 @@ public class DB { //System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork); } System.out.printf("Size of dates: %s\n", dates.size()); - return dates; + + // Returns a treemap that sorts the dates incrementally + return new TreeMap<>(dates); /* // Defining a treemap to sort through the data diff --git a/target/classes/com/application/DB/DB.class b/target/classes/com/application/DB/DB.class index 1da6ea92dcd6fd9b64697518553dd3ad7c737946..47892ca45240c43c584a1352c2c3f57b0bec5022 100644 Binary files a/target/classes/com/application/DB/DB.class and b/target/classes/com/application/DB/DB.class differ