Commit a052365d authored by bijingchen's avatar bijingchen

优化温湿度,增加空气质量参数

parent b5043884
...@@ -138,41 +138,60 @@ public class ArchiveInterfaceService { ...@@ -138,41 +138,60 @@ public class ArchiveInterfaceService {
} }
} }
//获取温湿度 //获取温湿度,空气质量
public void GetRoomWSD24List(int index, Record equipment) { public void GetRoomWSD24List(int index, Record equipment) {
System.err.println("GetRoomWSD24List>>>"); System.err.println("GetRoomWSD24List>>>");
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
Kv kv = new Kv(); Kv kv = new Kv();
List<Record> list = new ArrayList<>(); List<Record> list = new ArrayList<>();
kv.set("server_name", "温湿度").set("room_id", index).set("day", "0"); kv.set("server_name", "温湿度,空气质量").set("room_id", index).set("day", "0");
System.err.println(kv);
String jsonKv = JSONObject.toJSONString(kv); String jsonKv = JSONObject.toJSONString(kv);
String result = HttpRequestUtil.sendPost(url + "/GetRoomWSD24List", jsonKv); String result = HttpRequestUtil.sendPost(url + "/GetRoomWSD24List", jsonKv);
JSONObject jsonObject = JSON.parseObject(result); JSONObject jsonObject = JSON.parseObject(result);
JSONArray data = jsonObject.getJSONArray("data"); JSONArray data = jsonObject.getJSONArray("data");
int code = jsonObject.getInteger("code"); int code = jsonObject.getInteger("code");
String KZjsonKv = JSONObject.toJSONString(kv);
String KZresult = HttpRequestUtil.sendPost(url + "/GetRoomKQZL24List", KZjsonKv);
JSONObject KZjsonObject = JSON.parseObject(KZresult);
JSONArray KZdata = KZjsonObject.getJSONArray("data");
System.err.println(code); System.err.println(code);
if (code == 20015) { if (code == 20015) {
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
JSONObject dataObj = data.getJSONObject(i);
JSONObject KZdataObj = KZdata.getJSONObject(i);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, data.getJSONObject(i).getInteger("time")); calendar.set(Calendar.HOUR_OF_DAY, dataObj.getInteger("time"));
calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.SECOND, 0);
Calendar calendars = Calendar.getInstance();
calendars.set(Calendar.HOUR_OF_DAY, KZdataObj.getInteger("time"));
calendars.set(Calendar.MINUTE, 0);
calendars.set(Calendar.SECOND, 0);
Date dateTime = calendar.getTime(); Date dateTime = calendar.getTime();
list.add(new Record() Date dateTimes = calendars.getTime();
.set("ID", SlEnvironmentLog.SEQ_NEXTVAL)
Record record = new Record();
record.set("ID", SlEnvironmentLog.SEQ_NEXTVAL)
.set("EQUIPMENT_ID", equipment.get("id")) .set("EQUIPMENT_ID", equipment.get("id"))
.set("START_TIME",sdf.format(dateTime)) .set("START_TIME", sdf.format(dateTime))
.set("TEMP_LO", data.getJSONObject(i).get("temp")) .set("TEMP_LO", dataObj.get("temp"))
.set("TEMP_HI", data.getJSONObject(i).get("temp")) .set("TEMP_HI", dataObj.get("temp"))
.set("HUMIDITY_LO", data.getJSONObject(i).get("hum")) .set("HUMIDITY_LO", dataObj.get("hum"))
.set("HUMIDITY_HI", data.getJSONObject(i).get("hum")) .set("HUMIDITY_HI", dataObj.get("hum"))
.set("TEMP_LO_TIME", sdf.format(dateTime)) .set("TEMP_LO_TIME", sdf.format(dateTime))
.set("TEMP_HI_TIME", sdf.format(dateTime)) .set("TEMP_HI_TIME", sdf.format(dateTime))
.set("HUMIDITY_LO_TIME", sdf.format(dateTime)) .set("HUMIDITY_LO_TIME", sdf.format(dateTime))
.set("HUMIDITY_HI_TIME", sdf.format(dateTime)) .set("HUMIDITY_HI_TIME", sdf.format(dateTime))
.set("TEMP", data.getJSONObject(i).get("temp")) .set("PM25_HI", KZdataObj.get("pm25"))
.set("HUMIDITY", data.getJSONObject(i).get("hum"))); .set("PM25_HI_TIME", sdf.format(dateTimes))
.set("PM10_HI", KZdataObj.get("pm10"))
.set("PM10_HI_TIME", sdf.format(dateTimes))
.set("TEMP", dataObj.get("temp"))
.set("HUMIDITY", dataObj.get("hum"));
list.add(record);
} }
Db.batchSave("sl_environment_log", list, list.size()); Db.batchSave("sl_environment_log", list, list.size());
System.err.println("结束GetRoomWSD24List>>>"); System.err.println("结束GetRoomWSD24List>>>");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment