|
@@ -49,14 +49,12 @@ public class QueryEnergyUnitUsed {
|
|
}catch (ParseException e){
|
|
}catch (ParseException e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- return date.getTime();
|
|
|
|
|
|
+ return date.getTime()/1000;
|
|
}
|
|
}
|
|
|
|
|
|
// 查询用能电表统计数据信息
|
|
// 查询用能电表统计数据信息
|
|
public void QueryEnergyElectricUsed() {
|
|
public void QueryEnergyElectricUsed() {
|
|
- printJsonMessage("enter token","QueryEnergyElectricUsed");
|
|
|
|
getToken();
|
|
getToken();
|
|
- printJsonMessage("end token ","QueryEnergyElectricUsed");
|
|
|
|
|
|
|
|
// String ownerId = "";
|
|
// String ownerId = "";
|
|
//
|
|
//
|
|
@@ -77,14 +75,15 @@ public class QueryEnergyUnitUsed {
|
|
|
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
HashMap<String, String> map = new HashMap<>();
|
|
map.put("energyUnitId", "1");//用能单位编码
|
|
map.put("energyUnitId", "1");//用能单位编码
|
|
- map.put("energyUnitType","12");//用能单位类型(11:企业,12:单位)
|
|
|
|
|
|
+ map.put("energyUnitType","11");//用能单位类型(11:企业,12:单位)
|
|
map.put("energyType","1");//能源类型(1:电,2:水)
|
|
map.put("energyType","1");//能源类型(1:电,2:水)
|
|
map.put("circleType","1");//统计周期(1:小时,2:日,3:月)
|
|
map.put("circleType","1");//统计周期(1:小时,2:日,3:月)
|
|
map.put("dataTime",time);//查询时间(格式 yyyyMMddHH/yyyyMMdd/yyyyMM)
|
|
map.put("dataTime",time);//查询时间(格式 yyyyMMddHH/yyyyMMdd/yyyyMM)
|
|
try {
|
|
try {
|
|
JSONObject electricObject = queryData("queryEnergyUnitUsed", map, token);
|
|
JSONObject electricObject = queryData("queryEnergyUnitUsed", map, token);
|
|
String electricData = electricObject.getString("data");
|
|
String electricData = electricObject.getString("data");
|
|
- JSONObject dataObj = JSONObject.parseObject(electricData);
|
|
|
|
|
|
+ JSONArray array = JSON.parseArray(electricData);
|
|
|
|
+ JSONObject dataObj = JSONObject.parseObject(array.get(0).toString());
|
|
String dataTime = dataObj.getString("dataTime");
|
|
String dataTime = dataObj.getString("dataTime");
|
|
String energyValue = dataObj.getString("used");
|
|
String energyValue = dataObj.getString("used");
|
|
|
|
|
|
@@ -95,7 +94,7 @@ public class QueryEnergyUnitUsed {
|
|
mqttDataInfoVO.setDevice_id("ysdb0001");
|
|
mqttDataInfoVO.setDevice_id("ysdb0001");
|
|
mqttDataInfoVO.setProduct_id("512_YSNH");
|
|
mqttDataInfoVO.setProduct_id("512_YSNH");
|
|
mqttDataInfoVO.setTimestamp(getStringToDate(dataTime));
|
|
mqttDataInfoVO.setTimestamp(getStringToDate(dataTime));
|
|
- mqttDataInfoVO.setDevice_type("512");
|
|
|
|
|
|
+ mqttDataInfoVO.setDevice_type("512-nh");
|
|
|
|
|
|
if(mqttDataInfoVO != null){
|
|
if(mqttDataInfoVO != null){
|
|
mqttGateway.sendToMqtt("data-collector", JSONArray.toJSON(mqttDataInfoVO).toString());
|
|
mqttGateway.sendToMqtt("data-collector", JSONArray.toJSON(mqttDataInfoVO).toString());
|
|
@@ -128,14 +127,15 @@ public class QueryEnergyUnitUsed {
|
|
|
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
HashMap<String, String> map = new HashMap<>();
|
|
map.put("energyUnitId", "1");//用能单位编码
|
|
map.put("energyUnitId", "1");//用能单位编码
|
|
- map.put("energyUnitType","12");//用能单位类型(11:企业,12:单位)
|
|
|
|
|
|
+ map.put("energyUnitType","11");//用能单位类型(11:企业,12:单位)
|
|
map.put("energyType","2");//能源类型(1:电,2:水)
|
|
map.put("energyType","2");//能源类型(1:电,2:水)
|
|
map.put("circleType","1");//统计周期(1:小时,2:日,3:月)
|
|
map.put("circleType","1");//统计周期(1:小时,2:日,3:月)
|
|
map.put("dataTime",time);//查询时间(格式 yyyyMMddHH/yyyyMMdd/yyyyMM)
|
|
map.put("dataTime",time);//查询时间(格式 yyyyMMddHH/yyyyMMdd/yyyyMM)
|
|
try {
|
|
try {
|
|
- JSONObject electricObject = queryData("queryEnergyUnitUsed", map, token);
|
|
|
|
- String electricData = electricObject.getString("data");
|
|
|
|
- JSONObject dataObj = JSONObject.parseObject(electricData);
|
|
|
|
|
|
+ JSONObject waterObject = queryData("queryEnergyUnitUsed", map, token);
|
|
|
|
+ String waterData = waterObject.getString("data");
|
|
|
|
+ JSONArray array = JSON.parseArray(waterData);
|
|
|
|
+ JSONObject dataObj = JSONObject.parseObject(array.get(0).toString());
|
|
String dataTime = dataObj.getString("dataTime");
|
|
String dataTime = dataObj.getString("dataTime");
|
|
String energyValue = dataObj.getString("used");
|
|
String energyValue = dataObj.getString("used");
|
|
|
|
|
|
@@ -146,7 +146,7 @@ public class QueryEnergyUnitUsed {
|
|
mqttDataInfoVO.setDevice_id("yssb0001");
|
|
mqttDataInfoVO.setDevice_id("yssb0001");
|
|
mqttDataInfoVO.setProduct_id("512_YSNH");
|
|
mqttDataInfoVO.setProduct_id("512_YSNH");
|
|
mqttDataInfoVO.setTimestamp(getStringToDate(dataTime));
|
|
mqttDataInfoVO.setTimestamp(getStringToDate(dataTime));
|
|
- mqttDataInfoVO.setDevice_type("512");
|
|
|
|
|
|
+ mqttDataInfoVO.setDevice_type("512-nh");
|
|
|
|
|
|
if(mqttDataInfoVO != null){
|
|
if(mqttDataInfoVO != null){
|
|
mqttGateway.sendToMqtt("data-collector", JSONArray.toJSON(mqttDataInfoVO).toString());
|
|
mqttGateway.sendToMqtt("data-collector", JSONArray.toJSON(mqttDataInfoVO).toString());
|