Skip to content

Commit

Permalink
changes to add meter image,pipe size to meter
Browse files Browse the repository at this point in the history
  • Loading branch information
HariharanAnantharaman committed Apr 11, 2018
1 parent 83ea2d7 commit b8cf053
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,10 @@ private String getSeriesForMetrics(String metrics){
returnVal="supplyondata";
}else if ("meteroff".equalsIgnoreCase(metrics)){
returnVal="supplyoffdata";
}else if("consumerleakageontime".equalsIgnoreCase(metrics)){
returnVal="consumerleakageontime";
}else if("consumerleakageofftime".equalsIgnoreCase(metrics)){
returnVal="consumerleakageofftime";
}
return returnVal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ public class MeterConnection implements Serializable {
private String house_namenum;
private boolean isprivate;
private String metertype;
private String image;
private double pipesize;
private String pipesizeunit;

public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public double getPipesize() {
return pipesize;
}
public void setPipesize(double pipesize) {
this.pipesize = pipesize;
}
public String getPipesizeunit() {
return pipesizeunit;
}
public void setPipesizeunit(String pipesizeunit) {
this.pipesizeunit = pipesizeunit;
}
public String getMetertype() {
return metertype;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ public class MeterConnection implements Serializable {
private String house_namenum;
private boolean isprivate;
private String metertype;

private String image;
private double pipesize;
private String pipesizeunit;
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public double getPipesize() {
return pipesize;
}
public void setPipesize(double pipesize) {
this.pipesize = pipesize;
}
public String getPipesizeunit() {
return pipesizeunit;
}
public void setPipesizeunit(String pipesizeunit) {
this.pipesizeunit = pipesizeunit;
}
public String getMetertype() {
return metertype;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ public class MeterConnection implements Serializable {
private String house_namenum;
private boolean isprivate;
private String metertype;

private String image;
private double pipesize;
private String pipesizeunit;

public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public double getPipesize() {
return pipesize;
}
public void setPipesize(double pipesize) {
this.pipesize = pipesize;
}
public String getPipesizeunit() {
return pipesizeunit;
}
public void setPipesizeunit(String pipesizeunit) {
this.pipesizeunit = pipesizeunit;
}
public String getMetertype() {
return metertype;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ public class MeterConnection implements Serializable {
private String house_namenum;
private boolean isprivate;
private String metertype;

private String image;
private double pipesize;
private String pipesizeunit;

public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public double getPipesize() {
return pipesize;
}
public void setPipesize(double pipesize) {
this.pipesize = pipesize;
}
public String getPipesizeunit() {
return pipesizeunit;
}
public void setPipesizeunit(String pipesizeunit) {
this.pipesizeunit = pipesizeunit;
}
public String getMetertype() {
return metertype;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ public class WaterSupplyData implements Serializable {
private String metertype;

private String currentstatus;

private String image;
private double pipesize;
private String pipesizeunit;

public String getImage() {
return image;
}

public void setImage(String image) {
this.image = image;
}

public double getPipesize() {
return pipesize;
}

public void setPipesize(double pipesize) {
this.pipesize = pipesize;
}

public String getPipesizeunit() {
return pipesizeunit;
}

public void setPipesizeunit(String pipesizeunit) {
this.pipesizeunit = pipesizeunit;
}

public String getCurrentstatus() {
return currentstatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ public WaterSupplyData getLatestWaterSupplyData(int meterId) throws ClientProtoc
waterSupplyData.setCustomerId(connection.getCustomer_id());
waterSupplyData.setMetertype(connection.getMetertype());
waterSupplyData.setCurrentstatus(STATUS);
waterSupplyData.setImage(connection.getImage());
waterSupplyData.setPipesize(connection.getPipesize());
waterSupplyData.setPipesizeunit(connection.getPipesizeunit());

log.info("Exiting SupplyDataService.getLatestWaterSupplyData");
return waterSupplyData;
Expand Down
23 changes: 17 additions & 6 deletions test/src/test/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ public List<Data> getData(RequestData data) throws ParseException{

String groupVal = getGroupVal(data);

boolean useHours=false;

if(data.getSample_Distance().equalsIgnoreCase("Hour")){
useHours=true;
}
int deviceId=data.getHouse_ID();
//int deviceId=123;
String query = "select sum(value) from flowvalues where time >='"+startTime+"' and time<'"+endTime+"' and meter_id='"+deviceId+"' group by time("+groupVal+") fill(0)";// now() - 10d and meter_id = '124' group by time(1d) fill(0)
log.debug("Query is:"+query);


List<Data> retlist = getDailyMetrics(deviceId, query);
List<Data> retlist = getDailyMetrics(deviceId, query,useHours);
return retlist;
}

Expand Down Expand Up @@ -155,7 +159,7 @@ public List<Data> getDailyFowRateData(RequestData data) throws ParseException{
log.debug("Query is:"+query);


List<Data> retlist = getDailyMetrics(deviceId, query);
List<Data> retlist = getDailyMetrics(deviceId, query,false);
return retlist;
}

Expand Down Expand Up @@ -187,7 +191,7 @@ else if(data.getSample_Distance().equalsIgnoreCase("Hour")){
return groupVal;
}

private List<Data> getDailyMetrics(int deviceId, String query) {
private List<Data> getDailyMetrics(int deviceId, String query,boolean useHours) {
//InfluxDB influxDB = InfluxDBFactory.connect("http://localhost:32770", "root", "root");
InfluxDB influxDB = InfluxDBFactory.connect(influxProperties.getUrl(),influxProperties.getUsername(),influxProperties.getPassword());
long startStarttime=System.currentTimeMillis();
Expand All @@ -201,7 +205,7 @@ private List<Data> getDailyMetrics(int deviceId, String query) {
// int recordSize=0;
List<Data> retlist=new ArrayList<Data>();
// SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
//SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-ddTHH:mm:ssZ");
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
//Date date1=new SimpleDateFormat("yyyy-MM-DDTHH:mm:ssz").parse(sDate1);
Data resultData=null;
Expand All @@ -223,7 +227,14 @@ private List<Data> getDailyMetrics(int deviceId, String query) {

resultData=new Data();
resultData.setDevid(deviceId);
resultData.setName(endTimeReturned.split("T")[0]);
if(useHours){
Instant instant=Instant.parse(endTimeReturned);
Date date = Date.from(instant);
resultData.setName(dateFormat.format(date));
}else{
resultData.setName(endTimeReturned.split("T")[0]);
}

resultData.setValue(Math.round(((Double)results.get(1)).doubleValue()*100D)/100D);
resultData.setSensor_locationname(locationName);
retlist.add(resultData);
Expand Down Expand Up @@ -926,4 +937,4 @@ public void insertTimeSeriesData(SeriesPointData pointData){

}

}
}

0 comments on commit b8cf053

Please sign in to comment.