|
@@ -2297,3 +2297,168 @@ public class YtiotVAlarmServiceImpl implements YtiotVAlarmService {
|
|
|
json.put("RESULT", jSONArray);
|
|
|
}
|
|
|
}
|
|
|
+ return json.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getConfirmStatus(String queryJson) throws Exception {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ String company_code = null;
|
|
|
+ String company_code_list = null;
|
|
|
+ String company_name = null;
|
|
|
+ String device_code = null;
|
|
|
+ String device_code_list = null;
|
|
|
+ String time_start = null;
|
|
|
+ String time_end = null;
|
|
|
+ String clzt = null;
|
|
|
+ String COMMSTATUS = null;
|
|
|
+ String V_LOGINNAME = null;
|
|
|
+ String V_PASSWORD = null;
|
|
|
+ String hqlwhere = null;
|
|
|
+ String sqlwhere = null;
|
|
|
+ int E_STATUS=-1;
|
|
|
+ JSONObject q_json = null;
|
|
|
+ JSONArray jSONArray = new JSONArray();
|
|
|
+ JSONArray jSONArray2 = new JSONArray();
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ List list2 = null,list3 = null,list4 = null;
|
|
|
+ json.put("action", "getConfirmStatus");
|
|
|
+ if(queryJson!=null) {
|
|
|
+ q_json = JSONObject.fromObject(queryJson);
|
|
|
+ company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
|
|
|
+ time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
|
|
|
+ time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
|
|
|
+ COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
|
|
|
+ clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
|
|
|
+ if(q_json.has("company_code")) {
|
|
|
+ if((q_json.optJSONObject("company_code")!=null)&&(q_json.optJSONObject("company_code").isArray())) {
|
|
|
+ JSONArray j_tmp = q_json.getJSONArray("company_code");
|
|
|
+ for(int i=0;i<j_tmp.size();i++) {
|
|
|
+ if(i==0)
|
|
|
+ company_code_list = j_tmp.getString(i);
|
|
|
+ else
|
|
|
+ company_code_list += ","+j_tmp.getString(i);
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ company_code = q_json.getString("company_code");
|
|
|
+ }
|
|
|
+ if(q_json.has("device_code")) {
|
|
|
+ if(q_json.getJSONObject("device_code").isArray()) {
|
|
|
+ JSONArray j_tmp = q_json.getJSONArray("device_code");
|
|
|
+ for(int i=0;i<j_tmp.size();i++) {
|
|
|
+ if(i==0)
|
|
|
+ device_code_list = j_tmp.getString(i);
|
|
|
+ else
|
|
|
+ device_code_list += ","+j_tmp.getString(i);
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ device_code = q_json.getString("device_code");
|
|
|
+ }
|
|
|
+ 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 MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(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_name!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" company_name like '%"+company_name+"%' ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
|
|
|
+ }
|
|
|
+ if(time_start!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" time >= '"+time_start+"' ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+" time >= '"+time_start+"' ";
|
|
|
+ }
|
|
|
+ if(time_end!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" time <= '"+time_end+"' ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+" time <= '"+time_end+"' ";
|
|
|
+ }
|
|
|
+ if(company_code!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" company_code like '%"+company_code+"%' ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("company_code")+" like '%"+company_code+"%' ";
|
|
|
+ }
|
|
|
+ if(company_code_list!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" company_code in ("+company_code_list+") ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
|
|
|
+ }
|
|
|
+ if(device_code!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" device_code like '%"+device_code+"%' ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("device_code")+" like '%"+device_code+"%' ";
|
|
|
+ }
|
|
|
+ if(device_code_list!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" device_code in ("+device_code_list+") ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
|
|
|
+ }
|
|
|
+ if(clzt!=null) {
|
|
|
+ sqlwhere = chkhw(sqlwhere)+" clzt="+clzt+" ";
|
|
|
+ hqlwhere = chkhw(hqlwhere)+" u.id.clzt = "+clzt+" ";
|
|
|
+ }
|
|
|
+ String wheresql = null;
|
|
|
+ if(COMMSTATUS!=null) {
|
|
|
+ if(COMMSTATUS.equals("NO"))
|
|
|
+ wheresql = chkhw(sqlwhere)+" data1<>'U44' ";
|
|
|
+ else if(COMMSTATUS.equals("ONLY"))
|
|
|
+ wheresql = chkhw(sqlwhere)+" data1='U44' ";
|
|
|
+ else
|
|
|
+ wheresql = sqlwhere;
|
|
|
+ }else
|
|
|
+ wheresql = sqlwhere;
|
|
|
+ List list = ytiotVAlarmDao.queryBySQL(" select count(*) as count, sum(clzt) as sum from ytiot_v_hj "+((wheresql!=null)?wheresql:""));
|
|
|
+ if(list.size()>0) {
|
|
|
+ int NCount = 0;
|
|
|
+ for(Iterator iterator = list.iterator();iterator.hasNext();){
|
|
|
+ if(NCount==0) {
|
|
|
+ Object[] objects = (Object[]) iterator.next();
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("count", objects[0].toString());
|
|
|
+ map.put("sum", objects[1]==null?"0":objects[1].toString());
|
|
|
+ map.put("id", "fire_alarm");
|
|
|
+ list2 = ytiotVAlarmDao.HJQuery(hqlwhere, "order by u.id.id", "desc", "0", "1");
|
|
|
+ JSONObject jSONObject = JSONObject.fromObject(map);
|
|
|
+ jSONArray.add(jSONObject);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ NCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wheresql = null;
|
|
|
+ if(COMMSTATUS!=null) {
|
|
|
+ if(COMMSTATUS.equals("NO"))
|
|
|
+ wheresql = chkhw(sqlwhere)+" ( data1<>'WP4' and data1<>'LL4' ) ";
|
|
|
+ else if(COMMSTATUS.equals("ONLY"))
|
|
|
+ wheresql = chkhw(sqlwhere)+" (data1='WP4' or data1='LL4' ) ";
|
|
|
+ else
|
|
|
+ wheresql = sqlwhere;
|
|
|
+ }else
|
|
|
+ wheresql = sqlwhere;
|
|
|
+// System.out.println(" select count(*) as count, sum(clzt) as sum from ytiot_v_sj "+((wheresql!=null)?wheresql:""));
|
|
|
+ list = ytiotVAlarmDao.queryBySQL(" select count(*) as count, sum(clzt) as sum from ytiot_v_sj "+((wheresql!=null)?wheresql:""));
|
|
|
+ if(list.size()>0) {
|
|
|
+ int NCount = 0;
|
|
|
+ for(Iterator iterator = list.iterator();iterator.hasNext();){
|
|
|
+ if(NCount==0) {
|
|
|
+ Object[] objects = (Object[]) iterator.next();
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("count", objects[0].toString());
|
|
|
+ map.put("sum", objects[1]==null?"0":objects[1].toString());
|
|
|
+ map.put("id", "water_alarm");
|
|
|
+ list3 = ytiotVAlarmDao.SJQuery(hqlwhere, "order by u.id.id", "desc", "0", "1");
|
|
|
+ JSONObject jSONObject = JSONObject.fromObject(map);
|
|
|
+ jSONArray.add(jSONObject);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ NCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wheresql = null;
|
|
|
+ if(COMMSTATUS!=null) {
|
|
|
+ if(COMMSTATUS.equals("NO"))
|
|
|
+ wheresql = chkhw(sqlwhere)+" status<>'44' ";
|
|
|
+ else if(COMMSTATUS.equals("ONLY"))
|
|
|
+ wheresql = chkhw(sqlwhere)+" status='44' ";
|