|
@@ -3093,3 +3093,177 @@ public class YtiotVDataServiceImpl implements YtiotVDataService {
|
|
|
hqlwhere += " and u.id.dwtype='"+dwtype+"' ";
|
|
|
if(point_code!=null)
|
|
|
hqlwhere += " and u.id.pointCode="+point_code+" ";
|
|
|
+ List list = ytiotVDataDao.SyncStatusQuery(hqlwhere, null, null, null, null);
|
|
|
+ cmap.put("list_count", list.size());
|
|
|
+ if(list.size()>0) {
|
|
|
+ for(int j=0;j<list.size();j++) {
|
|
|
+ YtiotVSyncStatus o = (YtiotVSyncStatus)list.get(j);
|
|
|
+ YtiotVSyncStatusId oid = o.getId();
|
|
|
+ @SuppressWarnings("rawtypes")
|
|
|
+ Map<String, Comparable> map = new HashMap<String, Comparable>();
|
|
|
+ map.put("content", oid.getContent());
|
|
|
+ map.put("data_time", df.format(oid.getDataTime()));
|
|
|
+ map.put("device_id", oid.getDeviceId());
|
|
|
+ map.put("dwtype", oid.getDwtype());
|
|
|
+ map.put("name", oid.getName());
|
|
|
+ map.put("point_code", oid.getPointCode());
|
|
|
+ map.put("point_data", oid.getPointData());
|
|
|
+ JSONObject JObject = JSONObject.fromObject(map);
|
|
|
+ a_point.add(JObject);
|
|
|
+ if(dwtype==null) {
|
|
|
+ if(oid.getPointCode().equals("0")) {
|
|
|
+ if(!oid.getPointData().equals("0")) {
|
|
|
+ if(oid.getDwtype()==1)
|
|
|
+ fireAlarm = true;
|
|
|
+ else if(oid.getDwtype()==2)
|
|
|
+ waterAlarm = true;
|
|
|
+ else if(oid.getDwtype()==5)
|
|
|
+ waterAlarm = true;
|
|
|
+ else if(oid.getDwtype()==6)
|
|
|
+ rtuAlarm = true;
|
|
|
+ else if(oid.getDwtype()==7)
|
|
|
+ efireAlarm = true;
|
|
|
+ else
|
|
|
+ otherAlarm = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cmap.put("point_list", a_point);
|
|
|
+ }else {
|
|
|
+ if(ComId.getD1a()>ComId.getD1ac())
|
|
|
+ fireAlarm = true;
|
|
|
+ if((ComId.getD0a()+ComId.getD2a())>(ComId.getD0ac()+ComId.getD2ac()))
|
|
|
+ waterAlarm = true;
|
|
|
+ if(ComId.getD6a()>ComId.getD6ac())
|
|
|
+ otherAlarm = true;
|
|
|
+ }
|
|
|
+ cmap.put("fire_alarm", fireAlarm);
|
|
|
+ cmap.put("water_alarm", waterAlarm);
|
|
|
+ cmap.put("rtu_alarm", rtuAlarm);
|
|
|
+ cmap.put("efire_alarm", efireAlarm);
|
|
|
+ cmap.put("other_alarm", otherAlarm);
|
|
|
+ if(ComId.getOwnerId().equals("10122"))
|
|
|
+ cmap.put("has_video", true);
|
|
|
+ else
|
|
|
+ cmap.put("has_video", false);
|
|
|
+ JSONObject jSONObject = JSONObject.fromObject(cmap);
|
|
|
+ jSONArray.add(jSONObject);
|
|
|
+ }
|
|
|
+ if(dwtype==null) {
|
|
|
+ json.put("avelng", (maxlng+minlng)/2);
|
|
|
+ json.put("avelat", (maxlat+minlat)/2);
|
|
|
+ }
|
|
|
+ json.put("RESULT", jSONArray);
|
|
|
+
|
|
|
+ }
|
|
|
+// }
|
|
|
+ if((QUERY_FROM!=null)&&(COMMSTATUS!=null)&&(QUERY_FROM.equals("FRONTPAGE")&&(COMMSTATUS.equals("NO")))) {
|
|
|
+
|
|
|
+ String sql = "select count(*) as count, sum(clzt) as sum from ytiot_v_hj where data1<>'U44' "+((Company_Code_List!=null)?" and company_code in ("+Company_Code_List+")":"");
|
|
|
+ List list2 = null, list3 = null, list4 = null, list5 = null;
|
|
|
+ JSONArray jSONArray2 = new JSONArray();
|
|
|
+ JSONArray jSONArray3 = new JSONArray();
|
|
|
+ JSONArray jSONArray4 = new JSONArray();
|
|
|
+ sql = "select sum(d0) as d0, sum(d0o) as d0o, sum(d0oc) as d0oc, sum(d0a) as d0a, sum(d0ac) as d0ac, "
|
|
|
+ + " sum(d1) as d1, sum(d1o) as d1o, sum(d1oc) as d1oc, sum(d1a) as d1a, sum(d1ac) as d1ac,"
|
|
|
+ + " sum(d2) as d2, sum(d2o) as d2o, sum(d2oc) as d2oc, sum(d2a) as d2a, sum(d2ac) as d2ac,"
|
|
|
+ + " sum(d6) as d6, sum(d6o) as d6o, sum(d6oc) as d6oc, sum(d6a) as d6a, sum(d6ac) as d6ac, "
|
|
|
+ + " sum(d7) as d7, sum(d7o) as d7o, sum(d7oc) as d7oc, sum(d7a) as d7a, sum(d7ac) as d7ac "
|
|
|
+ + " from ytiot_v_company "+((Company_Code_List!=null)?" where owner_id in ("+Company_Code_List+") ":"");
|
|
|
+ List list = ytiotVAlarmDao.queryBySQL(sql);
|
|
|
+ if(list.size()>0) {
|
|
|
+ Object[] objects = (Object[]) list.get(0);
|
|
|
+ if(Integer.parseInt(objects[8].toString())>Integer.parseInt(objects[9].toString()))
|
|
|
+ list2 = ytiotVAlarmDao.HJQuery(" where u.id.data1<>'U44' "+((Company_Code_List!=null)?" and u.id.companyCode in ("+Company_Code_List+") ":""), "order by u.id.id", "desc", "0", "1");
|
|
|
+ if((Integer.parseInt(objects[3].toString())+Integer.parseInt(objects[13].toString()))
|
|
|
+ >(Integer.parseInt(objects[4].toString())+Integer.parseInt(objects[14].toString())))
|
|
|
+ list3 = ytiotVAlarmDao.SJQuery(" where u.id.data1<>'U44'"+((Company_Code_List!=null)?" and u.id.companyCode in ("+Company_Code_List+") ":""), " order by u.id.id ", "desc", "0", "1");
|
|
|
+ if(Integer.parseInt(objects[18].toString())>Integer.parseInt(objects[19].toString()))
|
|
|
+ list4 = ytiotVAlarmDao.RTUQuery(" where u.id.data1<>'U44'"+((Company_Code_List!=null)?" and u.id.companyCode in ("+Company_Code_List+") ":" "), " order by u.id.id ", "desc", "0", "1");
|
|
|
+ if(Integer.parseInt(objects[23].toString())>Integer.parseInt(objects[24].toString()))
|
|
|
+ list5 = ytiotVAlarmDao.queryBySQL("select id, company_name, name, data1, time, clzt from ytiot_v_efire where data1<>'EF9' "+((Company_Code_List!=null)?" and company_code in ("+Company_Code_List+")":"")+" order by id desc limit 0, 1");
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("id", "fire_info");
|
|
|
+ map.put("device", Integer.parseInt(objects[5].toString()));
|
|
|
+ map.put("out", Integer.parseInt(objects[6].toString()));
|
|
|
+ map.put("outConfirm", Integer.parseInt(objects[7].toString()));
|
|
|
+ map.put("alarm", Integer.parseInt(objects[8].toString()));
|
|
|
+ map.put("alarmConfirm", Integer.parseInt(objects[9].toString()));
|
|
|
+ JSONObject jSONObject = JSONObject.fromObject(map);
|
|
|
+ jSONArray2.add(jSONObject);
|
|
|
+ Map map2 = new HashMap();
|
|
|
+ map2.put("id", "water_info");
|
|
|
+ map2.put("device", Integer.parseInt(objects[0].toString())+Integer.parseInt(objects[10].toString()));
|
|
|
+ map2.put("out", Integer.parseInt(objects[1].toString())+Integer.parseInt(objects[11].toString()));
|
|
|
+ map2.put("outConfirm", Integer.parseInt(objects[2].toString())+Integer.parseInt(objects[12].toString()));
|
|
|
+ map2.put("alarm", Integer.parseInt(objects[3].toString())+Integer.parseInt(objects[13].toString()));
|
|
|
+ map2.put("alarmConfirm", Integer.parseInt(objects[4].toString())+Integer.parseInt(objects[14].toString()));
|
|
|
+ JSONObject jSONObject2 = JSONObject.fromObject(map2);
|
|
|
+ jSONArray2.add(jSONObject2);
|
|
|
+ Map map3 = new HashMap();
|
|
|
+ map3.put("id", "rtu_info");
|
|
|
+ map3.put("device", Integer.parseInt(objects[15].toString()));
|
|
|
+ map3.put("out", Integer.parseInt(objects[16].toString()));
|
|
|
+ map3.put("outConfirm", Integer.parseInt(objects[17].toString()));
|
|
|
+ map3.put("alarm", Integer.parseInt(objects[18].toString()));
|
|
|
+ map3.put("alarmConfirm", Integer.parseInt(objects[19].toString()));
|
|
|
+ JSONObject jSONObject3 = JSONObject.fromObject(map3);
|
|
|
+ jSONArray2.add(jSONObject3);
|
|
|
+ Map map4 = new HashMap();
|
|
|
+ map4.put("id","efire_info");
|
|
|
+ map4.put("device", Integer.parseInt(objects[20].toString()));
|
|
|
+ map4.put("out", Integer.parseInt(objects[21].toString()));
|
|
|
+ map4.put("outConfirm", Integer.parseInt(objects[22].toString()));
|
|
|
+ map4.put("alarm", Integer.parseInt(objects[23].toString()));
|
|
|
+ map4.put("alarmConfirm", Integer.parseInt(objects[24].toString()));
|
|
|
+ JSONObject jSONObject4 = JSONObject.fromObject(map4);
|
|
|
+ jSONArray2.add(jSONObject4);
|
|
|
+ list.clear();
|
|
|
+ }
|
|
|
+ json.put("confirm_status", jSONArray2);
|
|
|
+
|
|
|
+// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ YtiotVHjId HJid = new YtiotVHjId();
|
|
|
+ int maxIdx = 0;
|
|
|
+ Date dTmp = df.parse("1970-01-01 00:00:00");
|
|
|
+ HJid.setTime(df.parse("1970-01-01 00:00:00"));
|
|
|
+ if((list2!=null)&&(list2.size()>0)) {
|
|
|
+ YtiotVHj hj = (YtiotVHj)list2.get(0);
|
|
|
+ HJid = hj.getId();
|
|
|
+ if(HJid.getTime().getTime()>=dTmp.getTime())
|
|
|
+ maxIdx = 2;
|
|
|
+ }
|
|
|
+ YtiotVSjId SJid = new YtiotVSjId();
|
|
|
+ SJid.setTime(df.parse("1970-01-01 00:00:00"));
|
|
|
+ if((list3!=null)&&(list3.size()>0)) {
|
|
|
+ YtiotVSj sj = (YtiotVSj)list3.get(0);
|
|
|
+ SJid = sj.getId();
|
|
|
+ if(SJid.getTime().getTime()>=dTmp.getTime())
|
|
|
+ maxIdx = 3;
|
|
|
+ }
|
|
|
+ YtiotVRtuId RTUid = new YtiotVRtuId();
|
|
|
+ RTUid.setTime(df.parse("1970-01-01 00:00:00"));
|
|
|
+ if((list4!=null)&&(list4.size()>0)) {
|
|
|
+ YtiotVRtu rtu = (YtiotVRtu)list4.get(0);
|
|
|
+ RTUid = rtu.getId();
|
|
|
+ if(RTUid.getTime().getTime()>=dTmp.getTime())
|
|
|
+ maxIdx = 4;
|
|
|
+ }
|
|
|
+ if(list5!=null) {
|
|
|
+ Object[] objects = (Object[]) list5.get(0);
|
|
|
+ if(df.parse(objects[4].toString()).getTime()>=dTmp.getTime())
|
|
|
+ maxIdx = 5;
|
|
|
+ }
|
|
|
+ switch(maxIdx) {
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("id", 1);
|
|
|
+ map.put("company", HJid.getCompanyName());
|
|
|
+ map.put("name", HJid.getName()+((HJid.getData4().length()>0) ?(","+HJid.getData4()):""));
|
|
|
+ map.put("data", HJid.getData2());
|
|
|
+ map.put("time", df.format(HJid.getTime()));
|
|
|
+ map.put("clzt", HJid.getClzt()==1?"已处理":"未处理");
|
|
|
+ JSONObject jSONObject = JSONObject.fromObject(map);
|