|
@@ -3436,3 +3436,145 @@ public class YtiotVDataServiceImpl implements YtiotVDataService {
|
|
if(list.size()>0) {
|
|
if(list.size()>0) {
|
|
int Nrow = 0;
|
|
int Nrow = 0;
|
|
for(Iterator iterator = list.iterator();iterator.hasNext();){
|
|
for(Iterator iterator = list.iterator();iterator.hasNext();){
|
|
|
|
+ Object[] objects = (Object[]) iterator.next();
|
|
|
|
+ daylist.add(objects[0].toString());
|
|
|
|
+ String s_count = objects[1]==null?"0":objects[1].toString();
|
|
|
|
+ String s_sum = objects[2]==null?"0":objects[2].toString();
|
|
|
|
+ countlist.add(Integer.parseInt(s_count));
|
|
|
|
+ sumlist.add(Integer.parseInt(s_sum));
|
|
|
|
+ count += Integer.parseInt(s_count);
|
|
|
|
+ sum += Integer.parseInt(s_sum);
|
|
|
|
+ if((company_code!=null)&&(Nrow==0))
|
|
|
|
+ json.put("company_name", objects[3].toString());
|
|
|
|
+ Nrow++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Map map2 = new HashMap();
|
|
|
|
+ map2.put("day_list", daylist);
|
|
|
|
+ map2.put("count_list", countlist);
|
|
|
|
+ map2.put("sum_list", sumlist);
|
|
|
|
+ map2.put("count", count);
|
|
|
|
+ map2.put("sum", sum);
|
|
|
|
+ map2.put("id", "fire_alarm");
|
|
|
|
+ JSONObject jSONObject2 = JSONObject.fromObject(map2);
|
|
|
|
+ jSONArray.add(jSONObject2);
|
|
|
|
+ json.put("RESULT", jSONArray);
|
|
|
|
+ json.put("check", "true");
|
|
|
|
+ }else {
|
|
|
|
+ json.put("check", "false");
|
|
|
|
+ }
|
|
|
|
+ return json.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getSyncDataVListByCompany(String queryJson) throws Exception {
|
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
+ String company_code = null;
|
|
|
|
+ String device_id = null;
|
|
|
|
+ String dwtype = null;
|
|
|
|
+ String point_code = null;
|
|
|
|
+ String V_LOGINNAME = null;
|
|
|
|
+ String V_PASSWORD = null;
|
|
|
|
+ String hqlwhere = null;
|
|
|
|
+ String cqlwhere = null;
|
|
|
|
+ int E_STATUS=-1;
|
|
|
|
+ JSONObject q_json = null;
|
|
|
|
+ JSONArray jSONArray = new JSONArray();
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("action", "getSyncDataVListByCompany");
|
|
|
|
+ if(queryJson!=null) {
|
|
|
|
+ q_json = JSONObject.fromObject(queryJson);
|
|
|
|
+ if(q_json.has("company_code")) {
|
|
|
|
+ company_code = q_json.getString("company_code");
|
|
|
|
+ }
|
|
|
|
+ if(q_json.has("device_id")) {
|
|
|
|
+ device_id = q_json.getString("device_id");
|
|
|
|
+ }
|
|
|
|
+ dwtype = q_json.has("dwtype")?q_json.getString("dwtype"):null;
|
|
|
|
+ point_code = q_json.has("point_code")?q_json.getString("point_code"):null;
|
|
|
|
+ V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
|
|
|
|
+ V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
|
|
|
|
+ }
|
|
|
|
+ if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
|
|
|
|
+ List list = ytiotTAdminDao.query(" where u.VLoginname='"+V_LOGINNAME+"' and u.VPassword='"
|
|
|
|
+ +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
|
|
|
|
+ if(list.size()>0) {
|
|
|
|
+ YtiotTAdmin o = (YtiotTAdmin)list.get(0);
|
|
|
|
+ E_STATUS = Integer.parseInt(o.getEStatus());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(E_STATUS==1) {
|
|
|
|
+ if(company_code!=null)
|
|
|
|
+ cqlwhere = chkhw(cqlwhere) + " u.id."+fieldname("owner_id")+" like '%"+company_code+"%' ";
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ List c_list = ytiotVCompanyDao.query(cqlwhere, null, null, null, null);
|
|
|
|
+ if(c_list.size()>0) {
|
|
|
|
+ for(int i=0;i<c_list.size();i++) {
|
|
|
|
+ YtiotVCompany com = (YtiotVCompany)c_list.get(i);
|
|
|
|
+ YtiotVCompanyId ComId = com.getId();
|
|
|
|
+ Map<String, Comparable> cmap = new HashMap<String, Comparable>();
|
|
|
|
+ if((company_code!=null)&&(i==0))
|
|
|
|
+ json.put("company_name", ComId.getOwnerName());
|
|
|
|
+ cmap.put("company_name", ComId.getOwnerName());
|
|
|
|
+ cmap.put("fulladdress", ComId.getFulladdress());
|
|
|
|
+ cmap.put("xmlx", ComId.getXmlx());
|
|
|
|
+ cmap.put("company_code", ComId.getOwnerId());
|
|
|
|
+ cmap.put("building_name", ComId.getBuildingName());
|
|
|
|
+ cmap.put("rtmp", ComId.getRtmp());
|
|
|
|
+ hqlwhere = " where u.id."+fieldname("company_code")+" ='"+ComId.getOwnerId()+"' and u.id.pointCode>0 ";
|
|
|
|
+ if(dwtype!=null) {
|
|
|
|
+ if(dwtype.equals("2")||dwtype.equals("5"))
|
|
|
|
+ hqlwhere += " and ( u.id.dwtype='2' or u.id.dwtype='5' ) ";
|
|
|
|
+ else
|
|
|
|
+ hqlwhere += " and u.id.dwtype='"+dwtype+"' ";
|
|
|
|
+ if(point_code!=null)
|
|
|
|
+ hqlwhere += " and u.id.pointCode="+point_code+" ";
|
|
|
|
+ }
|
|
|
|
+ if(device_id!=null)
|
|
|
|
+ hqlwhere += " and u.id.deviceId='"+device_id+"' ";
|
|
|
|
+ JSONArray a_point = new JSONArray();
|
|
|
|
+ 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("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());
|
|
|
|
+ map.put("data_time", df.format(oid.getDataTime()));
|
|
|
|
+ JSONArray slist = new JSONArray();
|
|
|
|
+ JSONArray tlist = new JSONArray();
|
|
|
|
+ List sublist = ytiotVDataDao.SyncDataQuery(" where u.id.deviceId='"+oid.getDeviceId()+"' and u.id.pointCode='"+oid.getPointCode()+"' ", " order by u.id.data_time ", " desc ", null, null);
|
|
|
|
+ if(sublist.size()>0) {
|
|
|
|
+ for(int k=0;k<sublist.size();k++) {
|
|
|
|
+ YtiotVSyncData d = (YtiotVSyncData)sublist.get(k);
|
|
|
|
+ YtiotVSyncDataId dId = d.getId();
|
|
|
|
+ slist.add(Integer.parseInt(dId.getPointData()));
|
|
|
|
+ tlist.add(df.format(dId.getDataTime()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ map.put("data_list", slist);
|
|
|
|
+ map.put("time_list", tlist);
|
|
|
|
+ JSONObject JObject = JSONObject.fromObject(map);
|
|
|
|
+ a_point.add(JObject);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cmap.put("point_list", a_point);
|
|
|
|
+ JSONObject jSONObject = JSONObject.fromObject(cmap);
|
|
|
|
+ jSONArray.add(jSONObject);
|
|
|
|
+ }
|
|
|
|
+ json.put("RESULT", jSONArray);
|
|
|
|
+ }
|
|
|
|
+ json.put("check", "true");
|
|
|
|
+ }else {
|
|
|
|
+ json.put("check", "false");
|
|
|
|
+ }
|
|
|
|
+ return json.toString();
|
|
|
|
+ }
|
|
|
|
+}
|