-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Following changes as per Satish request
1. Changed request response structure of water and battery consumption 2. Changed date in response to String to have only date(no timestamp)
- Loading branch information
1 parent
a6059d0
commit c2da439
Showing
728 changed files
with
76,776 additions
and
36 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<section name="Workbench"> | ||
<section name="ResizableDialogBounds"> | ||
<item value="283" key="x"/> | ||
<item value="800" key="width"/> | ||
<item value="0" key="y"/> | ||
<item value="600" key="height"/> | ||
</section> | ||
</section> |
35 changes: 35 additions & 0 deletions
35
.metadata/.plugins/org.eclipse.core.resources/.history/0/10212bdd762e001814c0d2815b26d8fe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.techolution.mauritius.smartwater.connection.domain; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
public class WaterConsumptionResponseData implements Serializable { | ||
|
||
private String name; | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public List<Data> getSeries() { | ||
return series; | ||
} | ||
|
||
public void setSeries(List<Data> series) { | ||
this.series = series; | ||
} | ||
|
||
public List<Data> getData() { | ||
return series; | ||
} | ||
|
||
public void setData(List<Data> data) { | ||
this.series = data; | ||
} | ||
|
||
private List<Data> series; | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
.metadata/.plugins/org.eclipse.core.resources/.history/0/60be039f97260018180ee1d7e30fe76e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.techolution.mauritius.smartwater.service; | ||
|
||
import java.io.IOException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.List; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.apache.http.client.ClientProtocolException; | ||
import org.influxdb.InfluxDB; | ||
import org.influxdb.InfluxDBFactory; | ||
import org.influxdb.dto.Query; | ||
import org.influxdb.dto.QueryResult; | ||
import org.influxdb.dto.QueryResult.Result; | ||
import org.json.JSONException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.techolution.mauritius.smartwater.domain.MeterConnection; | ||
import com.techolution.mauritius.smartwater.domain.TotalConsolidatedConsumption; | ||
import com.techolution.mauritius.smartwater.repository.ConnectionDetailsRepository; | ||
|
||
@Component | ||
public class ConsolidatedDataService { | ||
private Log log = LogFactory.getLog(ConsolidatedDataService.class); | ||
|
||
private static final String INFLUX_ENDPOINT="http://localhost:32768/query?db=mauritius_smartwater&q="; | ||
|
||
@Autowired | ||
private ConnectionDetailsRepository connectionDetailsRepository; | ||
|
||
|
||
|
||
public List<MeterConnection> getAllConnections(){ | ||
|
||
log.info("Entering ConsolidatedDataService.getAllConnections "); | ||
List returnList= (List)connectionDetailsRepository.findAll(); | ||
log.info("Exiting ConsolidatedDataService.getAllConnections "); | ||
if(returnList == null) { | ||
log.debug("returnList size is null"); | ||
}else{ | ||
log.debug("List size is:"+returnList.size()); | ||
} | ||
|
||
return returnList; | ||
} | ||
|
||
public TotalConsolidatedConsumption getConsumptionForThisMonth() throws ClientProtocolException, IOException, JSONException{ | ||
|
||
|
||
Calendar calendar=Calendar.getInstance(); | ||
calendar.set(Calendar.DAY_OF_MONTH, 1); | ||
|
||
SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
String reformattedStr = null; | ||
reformattedStr = myFormat.format(calendar.getTime()); | ||
|
||
Calendar calendarlastmonth=Calendar.getInstance(); | ||
calendarlastmonth.set(Calendar.DAY_OF_MONTH, 1); | ||
calendarlastmonth.add(Calendar.MONTH, -1); | ||
|
||
|
||
//String query=INFLUX_ENDPOINT+"select sum(value) from flow where time >='"+reformattedStr+"'"; | ||
String query="select sum(value) from flow where time >='"+reformattedStr+"'"; | ||
|
||
String query_previousbucket="select sum(value) from flow where time >='"+reformattedStr+"'"; | ||
|
||
|
||
|
||
InfluxDB influxDB = InfluxDBFactory.connect("http://localhost:32768", "root", "root"); | ||
String dbName = "mauritius_smartwater"; | ||
QueryResult queryResult = influxDB.query(new Query(query, dbName)); | ||
List<Result> results=queryResult.getResults(); | ||
Result valueobj=results.get(0); | ||
List<List<Object>> values=valueobj.getSeries().get(0).getValues(); | ||
// String consumption=(String)(values.get(0).get(1)); | ||
Double consumption=(Double)(values.get(0).get(1)); | ||
log.debug("consumption:"+consumption); | ||
|
||
//TotalConsolidatedConsumption consolidatedConsumption=new TotalConsolidatedConsumption(Long.valueOf(consumption).longValue(), 100.00, 0.00, 0.00); | ||
TotalConsolidatedConsumption consolidatedConsumption=new TotalConsolidatedConsumption(consumption, 100.00, 0.00, 0.00); | ||
return consolidatedConsumption; | ||
|
||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.