瀏覽代碼

3dDisplayEngine YtiotVAlarmServiceImpl.java 吉超博 commit at 2021-03-19

吉超博 4 年之前
父節點
當前提交
8253c4c097
共有 1 個文件被更改,包括 166 次插入0 次删除
  1. 166 0
      3dDisplayEngine/buildingService/YtiotVAlarmServiceImpl.java

+ 166 - 0
3dDisplayEngine/buildingService/YtiotVAlarmServiceImpl.java

@@ -4110,3 +4110,169 @@ public class YtiotVAlarmServiceImpl implements YtiotVAlarmService {
 				}
 				if(company_code_list!=null) {
 					hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype !='火系统' AND `status`>24";
+					hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+company_code_list+") "+ "AND `status` ='离线'";
+				}
+			}
+		}else {
+			if(Company_Code_List!=null) {
+				hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND `status` ='离线'";
+				hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype !='火系统' AND `status`>24";
+				if(dwtype==6) {
+					sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='rtu' AND `status`>24";
+				}else if(dwtype==2) {
+					sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype IN ('液位','水系统') AND `status`>24";
+				}else if(dwtype==7) {
+					sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='电气火灾' AND `status`>24";
+				}else if(dwtype==16) {
+					sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='视频监测' AND `status`>24";
+				}else if(dwtype==128) {
+					sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='井盖监测' AND `status`>24";
+				}else if(dwtype==17) {
+					sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='电梯监测' AND `status`>24";
+				}
+				
+			}else {
+				if(company_code!=null) {
+					hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" = '"+company_code+ "' AND `status` ='离线'";
+					hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" =  '"+company_code+ "' AND dwtype !='火系统' AND `status`>24";
+					if(dwtype==6) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" =  '"+company_code+ "' AND dwtype ='rtu' AND `status`>24";
+					}else if(dwtype==2) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +"  =  '"+company_code+ "' AND dwtype IN ('液位','水系统') AND `status`>24";
+					}else if(dwtype==7) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +"  =  '"+company_code+ "' AND dwtype ='电气火灾' AND `status`>24";
+					}else if(dwtype==16) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +"  =  '"+company_code+ "' AND dwtype ='视频监测' AND `status`>24";
+					}else if(dwtype==128) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +"  =  '"+company_code+ "' AND dwtype ='井盖监测' AND `status`>24";
+					}else if(dwtype==17) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +"  =  '"+company_code+ "' AND dwtype ='电梯监测' AND `status`>24";
+					}
+				}
+				if(company_code_list!=null) {
+					hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+company_code_list+") "+ "AND `status` ='离线'";
+					hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype !='火系统' AND `status`>24";
+					if(dwtype==6) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='rtu' AND `status`>24";
+					}else if(dwtype==2) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype IN ('液位','水系统') AND `status`>24";
+					}else if(dwtype==7) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='电气火灾' AND `status`>24";
+					}else if(dwtype==16) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='视频监测' AND `status`>24";
+					}else if(dwtype==128) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='井盖监测' AND `status`>24";
+					}else if(dwtype==17) {
+						sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='电梯监测' AND `status`>24";
+					}
+				}
+			}
+		}
+		System.out.println("hjhql = " + hjhql);
+		String hjsql = hjhql;
+		Integer hjtotalCount = 0;
+		hjtotalCount = (Integer) hibernateTemplate.execute(new HibernateCallback() {
+		    @Override
+		    public Object doInHibernate(Session session) throws HibernateException, SQLException {
+
+		        return Integer.valueOf(session.createSQLQuery(hjsql).uniqueResult().toString());
+
+
+		    }
+		});
+		String sonsql = sonhql;
+		Integer sontotalCount =0;
+		Integer totalCount = 0;
+		if(dwtype!=1) {
+			sontotalCount = (Integer) hibernateTemplate.execute(new HibernateCallback() {
+			    @Override
+			    public Object doInHibernate(Session session) throws HibernateException, SQLException {
+
+			        return Integer.valueOf(session.createSQLQuery(sonsql).uniqueResult().toString());
+
+
+			    }
+			});
+			json.put("sontotalCount", sontotalCount);
+		}
+		
+		String sql = hql;
+		totalCount = (Integer) hibernateTemplate.execute(new HibernateCallback() {
+		    @Override
+		    public Object doInHibernate(Session session) throws HibernateException, SQLException {
+
+		        return Integer.valueOf(session.createSQLQuery(sql).uniqueResult().toString());
+
+
+		    }
+		});
+		NumberFormat numberFormat = NumberFormat.getInstance();
+		String hjresult = numberFormat.format((float)hjtotalCount/(float)(totalCount+hjtotalCount)*100);
+		if(dwtype!=1) {
+			String sonresult = numberFormat.format((float)sontotalCount/(float)(totalCount+hjtotalCount)*100);
+			json.put("sonresult", sonresult);
+		}
+//		int totalCount = ytiotVAlarmDao.getHjOfflineCount(hqlwhere);
+		json.put("hjtotalCount", hjtotalCount);
+		json.put("hjresult", hjresult);
+		json.put("limit", Limit);
+		}
+		return json.toString();
+	}
+		
+	/**
+	 * 伍继告警信息
+	 */
+	@Override
+	public String getWjAlarmList(String queryJson, String page, String start, String limit, String sort) throws Exception {
+		// TODO Auto-generated method stub
+		String address = null;
+		String clzt = null;
+		String company_code = null;
+		String company_code_list = null;
+		String Company_Code_List = null;
+		String company_name = null;
+		String digitalValue = null;
+		String device_code_list = null;
+		String time_start = null;
+		String time_end = null;
+		String COMMSTATUS = null;
+		String V_LOGINNAME = null;
+		String hqlwhere = null;
+		String order = " order by id";
+		String dir = " desc";
+		String Start = null;
+		String Limit = null;
+		String Page = null;
+		String order_str = " order by id";
+		JSONObject q_json = null;
+		JSONArray Sort = null;
+		JSONArray jSONArray = new JSONArray();
+		JSONObject json = new JSONObject();
+		json.put("action", "getLiftVList");
+		NumberFormat numberFormat = NumberFormat.getInstance();
+		if(queryJson!=null) {
+			q_json = JSONObject.fromObject(queryJson);
+			V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
+			digitalValue = q_json.has("digitalValue")?q_json.getString("digitalValue"):null;
+			time_start = q_json.has("startTime")?q_json.getString("startTime"):null;
+			time_end = q_json.has("endTime")?q_json.getString("endTime"):null;
+			if(digitalValue!=null) {
+				if(digitalValue.equals("复归")) {
+					hqlwhere = chkhw(hqlwhere) + " u.digitalValue"+" = "+0+"";
+				}else if(digitalValue.equals("动作")) {
+					hqlwhere = chkhw(hqlwhere) + " u.digitalValue"+" = "+1+"";
+				}
+			}
+			if((time_start!=null)&&(time_start.length()>0)) {
+				hqlwhere = chkhw(hqlwhere) + " u.sendingTime >= '"+time_start+"' ";
+			}
+			if((time_end!=null)&&(time_start.length()>0)) {
+				hqlwhere = chkhw(hqlwhere) + " u.sendingTime <= '"+time_end+"' ";
+			}
+		int totalCount = ytiotVAlarmDao.getWjAlarmCount(hqlwhere);
+		json.put("totalCount", totalCount);
+		if(Start!=null){
+			if(Integer.parseInt(Start)>totalCount){
+				Start = "0";
+				Page = "0";