| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082 | package cn.com.usky.iot.company.service;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Calendar;import java.text.NumberFormat;import cn.com.usky.iot.admin.dao.YtiotTAdminDao;import cn.com.usky.iot.admin.dao.YtiotVUserCompanyDao;import cn.com.usky.iot.company.dao.YtiotVCompanyDao;import cn.com.usky.iot.entity.YtiotTAdmin;import cn.com.usky.iot.entity.YtiotTInspectors;import cn.com.usky.iot.entity.YtiotVCompany;import cn.com.usky.iot.entity.YtiotVCompanyId;import cn.com.usky.iot.entity.YtiotVUsercompany;import cn.com.usky.iot.entity.YtiotVUsercompanyId;import cn.com.usky.iot.entity.YtiotTProjectDetails;import cn.com.usky.iot.entity.YtiotTProjectDevice;import cn.com.usky.iot.entity.YtiotTProjectMonitor;import cn.com.usky.iot.entity.YtiotVEfire;import cn.com.usky.iot.entity.YtiotVEfireId;import cn.com.usky.iot.entity.YtiotVHj;import cn.com.usky.iot.entity.YtiotVHjId;import cn.com.usky.iot.entity.YtiotVRtu;import cn.com.usky.iot.entity.YtiotVRtuId;import cn.com.usky.iot.entity.YtiotVSj;import cn.com.usky.iot.entity.YtiotVSjId;import cn.com.usky.iot.alarm.dao.YtiotVAlarmDao;import cn.com.usky.iot.data.dao.YtiotVDataDao;import cn.com.usky.iot.entity.YtiotVEfire;import cn.com.usky.iot.entity.YtiotVEfireId;import cn.com.usky.iot.entity.YtiotVHj;import cn.com.usky.iot.entity.YtiotVHjId;import cn.com.usky.iot.entity.YtiotVRtu;import cn.com.usky.iot.entity.YtiotVRtuId;import cn.com.usky.iot.entity.YtiotVSj;import cn.com.usky.iot.entity.YtiotVSjId;import cn.com.usky.utils.MD5Util;import net.sf.json.JSONArray;import net.sf.json.JSONObject;import java.math.BigDecimal;import java.text.DecimalFormat;import java.text.ParseException;import java.text.SimpleDateFormat;public class YtiotVCompanyServiceImpl implements YtiotVCompanyService {	private YtiotVCompanyDao ytiotVCompanyDao;	private YtiotTAdminDao ytiotTAdminDao;	private YtiotVUserCompanyDao ytiotVUserCompanyDao;	private YtiotVAlarmDao ytiotVAlarmDao;	private YtiotVDataDao ytiotVDataDao;	public YtiotVDataDao getYtiotVDataDao() {		return ytiotVDataDao;	}	public void setYtiotVDataDao(YtiotVDataDao ytiotVDataDao) {		this.ytiotVDataDao = ytiotVDataDao;	}		public YtiotVAlarmDao getYtiotVAlarmDao() {		return ytiotVAlarmDao;	}	public void setYtiotVAlarmDao(YtiotVAlarmDao ytiotVAlarmDao) {		this.ytiotVAlarmDao = ytiotVAlarmDao;	}		public YtiotVUserCompanyDao getYtiotVUserCompanyDao() {		return ytiotVUserCompanyDao;	}	public void setYtiotVUserCompanyDao(YtiotVUserCompanyDao ytiotVUserCompanyDao) {		this.ytiotVUserCompanyDao = ytiotVUserCompanyDao;	}	public YtiotVCompanyDao getYtiotVCompanyDao() {		return ytiotVCompanyDao;	}	public void setYtiotVCompanyDao(YtiotVCompanyDao ytiotVCompanyDao) {		this.ytiotVCompanyDao = ytiotVCompanyDao;	}	public YtiotTAdminDao getYtiotTAdminDao() {		return ytiotTAdminDao;	}	public void setYtiotTAdminDao(YtiotTAdminDao ytiotTAdminDao) {		this.ytiotTAdminDao = ytiotTAdminDao;	}	public boolean chk_string_param(String param) {		if(param==null)			return true;		if(param.indexOf("=")>=0)			return false;		if(param.indexOf("\'")>=0)			return false;		if(param.indexOf("\"")>=0)			return false;		return true;	}		public String chkhw(String hqlwhere){		if(hqlwhere==null)			return " where ";		else			return hqlwhere+" and ";	}		public String fieldname(String field){		if(field.equals("building_id"))			return "buildingId";		if(field.equals("building_name"))			return "buildingName";		if(field.equals("create_man"))			return "createMan";		if(field.equals("create_time"))			return "createTime";		if(field.equals("owner_address"))			return "ownerAddress";		if(field.equals("owner_id"))			return "ownerId";		if(field.equals("owner_man"))			return "ownerMan";		if(field.equals("owner_name"))			return "ownerName";		if(field.equals("owner_office"))			return "ownerOffice";		if(field.equals("company_code"))			return "companyCode";		return field;	}	@Override	public String getVCompanyList(String queryJson, String page, String start, String limit, String sort)			throws Exception {		// TODO Auto-generated method stub		String addr1=null, addr2=null, addr3=null;		String addr1list=null, addr2list=null, addr3list=null;		String address=null, building_id=null, building_name=null, create_man=null;		String data1=null, data2=null, data3=null, fulladdress=null;		String h5=null, hls=null, id=null, owner_address=null;		String owner_id=null, owner_man=null, owner_name=null;		String owner_id_list=null, building_id_list=null;		String owner_office=null, rtmp=null, xmlx=null, xmlx_list=null;		String hqlwhere = null;		String order = null;		String dir = null;		String Start = null;		String Limit = null;		String Page = null;		String order_str = null;		JSONObject q_json = null;		JSONArray Sort = null;		JSONArray jSONArray = new JSONArray();		JSONObject json = new JSONObject();		json.put("action", "getVCompanyList");		if(queryJson!=null) {			q_json = JSONObject.fromObject(queryJson);			if(q_json.has("addr1")) {				if(((JSONObject) q_json.get("addr1")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("addr1");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							addr1list = tmp;						else							addr1list += ","+tmp;					}				}else					addr1 = q_json.getString("addr1");			}			if(q_json.has("addr2")) {				if(((JSONObject) q_json.getJSONObject("addr2")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("addr2");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							addr2list = tmp;						else							addr2list += ","+tmp;					}				}else					addr2 = q_json.getString("addr2");			}			if(q_json.has("addr3")) {				if(((JSONObject)q_json.getJSONObject("addr3")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("addr3");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							addr3list = tmp;						else							addr3list += ","+tmp;					}				}else					addr3 = q_json.getString("addr3");			}			address = q_json.has("address")?q_json.getString("address"):null;			if(q_json.has("building_id")) {				if(((JSONObject)q_json.getJSONObject("building_id")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("building_id");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							building_id_list = tmp;						else							building_id_list += ","+tmp;					}				}else					building_id = q_json.getString("building_id");			}			building_name = q_json.has("building_name")?q_json.getString("building_name"):null;			create_man = q_json.has("create_man")?q_json.getString("create_man"):null;			data1 = q_json.has("data1")?q_json.getString("data1"):null;			data2 = q_json.has("data2")?q_json.getString("data2"):null;			data3 = q_json.has("data3")?q_json.getString("data3"):null;			fulladdress = q_json.has("fulladdress")?q_json.getString("fulladdress"):null;			id = q_json.has("id")?q_json.getString("id"):null;			if(q_json.has("owner_id"))			{				if(((JSONObject)q_json.getJSONObject("owner_id")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("owner_id");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							owner_id_list = tmp;						else							owner_id_list += ","+tmp;					}				}else					owner_id = q_json.getString("owner_id");			}			owner_address = q_json.has("owner_address")?q_json.getString("owner_address"):null;			owner_office = q_json.has("owner_office")?q_json.getString("owner_office"):null;			if(q_json.has("xmlx")) {				if(((JSONObject)q_json.getJSONObject("xmlx")).isArray()) {					JSONArray j_tmp = q_json.getJSONArray("xmlx");					for(int i=0;i<j_tmp.size();i++) {						String tmp = j_tmp.getString(i);						if(i==0)							xmlx_list = "'"+tmp+"'";						else							xmlx_list += ",'"+tmp+"'";					}				}else					xmlx = q_json.getString("xmlx");			}			xmlx = q_json.has("xmlx")?q_json.getString("xmlx"):null;			order = q_json.has("order")?q_json.getString("order"):null;			dir = q_json.has("dir")?q_json.getString("dir"):null;			Start = q_json.has("start")?q_json.getString("start"):(start!=null)?start:"0";			Limit = q_json.has("limit")?q_json.getString("limit"):(limit!=null)?limit:null;			Page = q_json.has("page")?q_json.getString("page"):(page!=null)?page:"0";			json.put("query", queryJson);		}		if(sort!=null) {			Sort = JSONArray.fromObject(sort);			if((Sort.isArray())&&(Sort.size()>0)) {				JSONObject s_json = Sort.getJSONObject(0);				order = s_json.has("property")?s_json.getString("property"):order;				dir = s_json.has("direction")?s_json.getString("direction"):dir;			}			json.put("sort", sort);		}		Start = start;		Limit = limit;		Page = page;		if(addr1!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" like '%"+addr1+"%' ";		if(addr1list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" in ("+addr1list+") ";		if(addr2!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" like '%"+addr2+"%' ";		if(addr2list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" in ("+addr2list+") ";		if(addr3!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" like '%"+addr3+"%' ";		if(addr3list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" in ("+addr3list+") ";		if(address!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("address")+" like '%"+address+"%' ";		if(building_id!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" like '%"+building_id+"%' ";		if(building_id_list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" in ("+building_id_list+") ";		if(building_name!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_name")+" like '%"+building_name+"%' ";		if(create_man!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("create_man")+" like '%"+create_man+"%' ";		if(data1!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data1")+" like '%"+data1+"%' ";		if(data2!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data2")+" like '%"+data2+"%' ";		if(data3!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data3")+" like '%"+data3+"%' ";		if(fulladdress!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("fulladdress")+" like '%"+fulladdress+"%' ";		if(id!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("id")+" = '"+id+"' ";		if(owner_id!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" = "+owner_id+" ";		if(owner_id_list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_list+") ";		if(owner_address!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_address")+" like '%"+owner_address+"%' ";		if(owner_office!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_office")+" like '%"+owner_office+"%' ";		if(xmlx!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" like '%"+xmlx+"%' ";		if(xmlx_list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" in ("+xmlx_list+") ";		if(order!=null) 			order_str = " order by u.id."+fieldname(order);		else			order_str = " order by u.id."+fieldname("id");		int totalCount = ytiotVCompanyDao.getCount(hqlwhere);		json.put("totalCount", totalCount);		if(Start!=null){			if(Integer.parseInt(Start)>totalCount){				Start = "0";				Page = "0";			}			if(page==null)				Page="0";		}else{			Start = "0";			Page = "0";		}		json.put("page", Page);		json.put("start", Start);		json.put("limit", Limit);		if(totalCount>0) {			List list = ytiotVCompanyDao.query(hqlwhere, order_str, dir, Start, Limit);			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");			if(list.size()>0) {				for(int i=0;i<list.size();i++) {					YtiotVCompany o = (YtiotVCompany)list.get(i);					YtiotVCompanyId Id = o.getId();					Map map = new HashMap();					map.put("addr1", Id.getAddr1());					map.put("addr2", Id.getAddr2());					map.put("addr3", Id.getAddr3());					map.put("address", Id.getAddress());					map.put("building_id", Id.getBuildingId());					map.put("building_name", Id.getBuildingName());					map.put("create_man", Id.getCreateMan());					map.put("create_time",  df.format(Id.getCreateTime()));					map.put("data1", Id.getData1());					map.put("data2", Id.getData2());					map.put("data3", Id.getData3());					map.put("fulladdress", Id.getFulladdress());					map.put("h5", Id.getH5());					map.put("hls", Id.getHls());					map.put("id", Id.getId());					map.put("owner_address", Id.getOwnerAddress());					map.put("owner_id", Id.getOwnerId());					map.put("owner_man", Id.getOwnerMan());					map.put("owner_name", Id.getOwnerName());					map.put("owner_office", Id.getOwnerOffice());					map.put("position", Id.getPosition());					map.put("rtmp", Id.getRtmp());					map.put("xmlx", Id.getXmlx());					JSONObject jSONObject = JSONObject.fromObject(map);					jSONArray.add(jSONObject);				}				json.put("RESULT", jSONArray);			}		}		return json.toString();	}	@Override	public String getVCompanyNameList(String queryJson) throws Exception {		// TODO Auto-generated method stub		String addr1=null, addr2=null, addr3=null;		String addr1list=null, addr2list=null, addr3list=null;		String address=null, building_id=null, building_name=null, create_man=null;		String data1=null, data2=null, data3=null, fulladdress=null;		String h5=null, hls=null, id=null, owner_address=null;		String owner_id=null, owner_man=null, owner_name=null;		String owner_id_list=null, building_id_list=null;		String owner_office=null, rtmp=null, xmlx=null, xmlx_list=null;		String V_LOGINNAME = null;		String V_PASSWORD = null;		String owner_id_List = null;		int E_STATUS=-1;		String hqlwhere = null;		JSONObject q_json = null;		JSONArray Sort = null;		JSONArray jSONArray = new JSONArray();		JSONObject json = new JSONObject();		json.put("action", "getVCompanyNameList");		if(queryJson!=null) {			q_json = JSONObject.fromObject(queryJson);			if(q_json.has("addr1")) {				if(((JSONObject) q_json.get("addr1")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("addr1");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							addr1list = tmp;						else							addr1list += ","+tmp;					}				}else					addr1 = q_json.getString("addr1");			}			if(q_json.has("addr2")) {				if(((JSONObject) q_json.getJSONObject("addr2")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("addr2");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							addr2list = tmp;						else							addr2list += ","+tmp;					}				}else					addr2 = q_json.getString("addr2");			}			if(q_json.has("addr3")) {				if(((JSONObject)q_json.getJSONObject("addr3")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("addr3");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							addr3list = tmp;						else							addr3list += ","+tmp;					}				}else					addr3 = q_json.getString("addr3");			}			address = q_json.has("address")?q_json.getString("address"):null;			if(q_json.has("building_id")) {				if(((JSONObject)q_json.getJSONObject("building_id")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("building_id");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							building_id_list = tmp;						else							building_id_list += ","+tmp;					}				}else					building_id = q_json.getString("building_id");			}			building_name = q_json.has("building_name")?q_json.getString("building_name"):null;			create_man = q_json.has("create_man")?q_json.getString("create_man"):null;			data1 = q_json.has("data1")?q_json.getString("data1"):null;			data2 = q_json.has("data2")?q_json.getString("data2"):null;			data3 = q_json.has("data3")?q_json.getString("data3"):null;			fulladdress = q_json.has("fulladdress")?q_json.getString("fulladdress"):null;			id = q_json.has("id")?q_json.getString("id"):null;			if(q_json.has("owner_id"))			{				if(((JSONObject)q_json.getJSONObject("owner_id")).isArray())				{					JSONArray j_tmp = q_json.getJSONArray("owner_id");					for(int i=0;i<j_tmp.size();i++)					{						String tmp = j_tmp.getString(i);						if(i==0)							owner_id_list = tmp;						else							owner_id_list += ","+tmp;					}				}else					owner_id = q_json.getString("owner_id");			}			owner_address = q_json.has("owner_address")?q_json.getString("owner_address"):null;			owner_office = q_json.has("owner_office")?q_json.getString("owner_office"):null;			if(q_json.has("xmlx")) {				if(((JSONObject)q_json.getJSONObject("xmlx")).isArray()) {					JSONArray j_tmp = q_json.getJSONArray("xmlx");					for(int i=0;i<j_tmp.size();i++) {						String tmp = j_tmp.getString(i);						if(i==0)							xmlx_list = "'"+tmp+"'";						else							xmlx_list += ",'"+tmp+"'";					}				}else					xmlx = q_json.getString("xmlx");			}			xmlx = q_json.has("xmlx")?q_json.getString("xmlx"):null;			json.put("query", queryJson);			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());			}			String where = " where u.id.agentid='"+V_LOGINNAME+"' ";			List list1 = ytiotVUserCompanyDao.query(where, null, null, null, null);			if(list1.size()>0) {				for(int i=0;i<list1.size();i++) {					YtiotVUsercompany o = (YtiotVUsercompany)list1.get(i);					YtiotVUsercompanyId oid = o.getId();					if(i==0)						owner_id_List = oid.getOwnerCode();					else						owner_id_List += ","+oid.getOwnerCode();				}			}		}		if(addr1!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" like '%"+addr1+"%' ";		if(addr1list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" in ("+addr1list+") ";		if(owner_id_List!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_List+") ";		if(addr2!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" like '%"+addr2+"%' ";		if(addr2list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" in ("+addr2list+") ";		if(addr3!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" like '%"+addr3+"%' ";		if(addr3list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" in ("+addr3list+") ";		if(address!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("address")+" like '%"+address+"%' ";		if(building_id!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" like '%"+building_id+"%' ";		if(building_id_list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" in ("+building_id_list+") ";		if(building_name!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_name")+" like '%"+building_name+"%' ";		if(create_man!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("create_man")+" like '%"+create_man+"%' ";		if(data1!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data1")+" like '%"+data1+"%' ";		if(data2!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data2")+" like '%"+data2+"%' ";		if(data3!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data3")+" like '%"+data3+"%' ";		if(fulladdress!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("fulladdress")+" like '%"+fulladdress+"%' ";		if(id!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("id")+" = '"+id+"' ";		if(owner_id!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" = "+owner_id+" ";		if(owner_id_list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_list+") ";		if(owner_address!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_address")+" like '%"+owner_address+"%' ";		if(owner_office!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_office")+" like '%"+owner_office+"%' ";		if(xmlx!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" like '%"+xmlx+"%' ";		if(xmlx_list!=null)			hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" in ("+xmlx_list+") ";		int totalCount = ytiotVCompanyDao.getCount(hqlwhere);		json.put("totalCount", totalCount);		if(totalCount>0) {			List list = ytiotVCompanyDao.query(hqlwhere, null, null, null, null);			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");			if(list.size()>0) {				for(int i=0;i<list.size();i++) {					YtiotVCompany o = (YtiotVCompany)list.get(i);					YtiotVCompanyId Id = o.getId();					Map map = new HashMap();					map.put("owner_id", Id.getOwnerId());					map.put("owner_name", Id.getOwnerName());					map.put("xmlx", Id.getXmlx());					JSONObject jSONObject = JSONObject.fromObject(map);					jSONArray.add(jSONObject);				}				json.put("RESULT", jSONArray);			}		}		return json.toString();	}			@Override	public String getVBuildingNameList(String queryJson) throws Exception {		String V_LOGINNAME = null;		String company_code_list = null;				String hqlwhere = null;		JSONObject q_json = null;				JSONArray jSONArray = new JSONArray();		JSONObject json = new JSONObject();//		json.put("action", "getPatrolPointList");		if(queryJson!=null) {			q_json = JSONObject.fromObject(queryJson);			V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;			json.put("query", queryJson);		}						if(V_LOGINNAME!=null) {				String where1 = " where u.id.agentid='"+V_LOGINNAME+"' ";				List list1 = ytiotVUserCompanyDao.query(where1, null, null, null, null);				if(list1.size()>0) {					for(int i=0;i<list1.size();i++) {						YtiotVUsercompany o = (YtiotVUsercompany)list1.get(i);						YtiotVUsercompanyId oid = o.getId();						if(i==0)							company_code_list = "'"+oid.getOwnerCode()+"'";						else							company_code_list += ",'"+oid.getOwnerCode()+"'";					}				}			}						if(company_code_list!=null)				hqlwhere = " where u.id.ownerId in ("+company_code_list+")";				List list = ytiotVCompanyDao.query(hqlwhere, null, null, null, null);				if(list.size()>0) {					for(int i=0;i<list.size();i++) {						YtiotVCompany o = (YtiotVCompany)list.get(i);						YtiotVCompanyId Id = o.getId();						Map map = new HashMap();						map.put("building_id", Id.getBuildingId());						map.put("building_name", Id.getBuildingName());						JSONObject jSONObject = JSONObject.fromObject(map);						jSONArray.add(jSONObject);					}					json.put("RESULT", jSONArray);				}		return json.toString();	}	public static int getDates(Date date1,Date date2) {		Calendar cal=Calendar.getInstance();		cal.setTime(date1);		long time1 = cal.getTimeInMillis();		cal.setTime(date2);		long time2 = cal.getTimeInMillis();		long between_days=(time2-time1)/(1000*3600*24);		return Integer.parseInt(String.valueOf(between_days));    }		@Override	public String getVProjectNameList(String queryJson) throws Exception {		// TODO Auto-generated method stub		String V_LOGINNAME = null;		String V_PASSWORD = null;		String start_data = null;		String end_data = null;		String company_code = null;		String device_type = null;		String video_type = null;		int E_STATUS=-1;		int m=0;		int q=0;		int x=0;		long days2=0;		long days5=0;		long days8=0;		String hqlwhere = null;		String hhwhere = null;		String hswhere = null;		String hrwhere = null;		String hewhere = null;		String efwhere = null;		String efrwhere = null;		String videowhere = null;		String videorwhere = null;		String sjwhere = null;		String sjrwhere = null;		String rtuwhere = null;		String rturwhere = null;		String dwwhere = null;		String dwsjwhere = null;		String dwrtuwhere = null;		String dwefwhere = null;		String dwvideowhere = null;		String hjresult = null;		String lxhjresult = null;		String sjresult = null;		String lxsjresult = null;		String rturesult = null;		String lxrturesult = null;		String efresult = null;		String lxefresult = null;		String videoresult = null;		JSONObject q_json = null;		JSONArray Sort = null;		JSONArray jSONArray = new JSONArray();		JSONArray jSONArray1 = new JSONArray();		JSONArray jSONArray2 = new JSONArray();		JSONArray jSONArray4 = new JSONArray();		JSONObject json = new JSONObject();		json.put("action", "getVProjectNameList");		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");		if(queryJson!=null) {			q_json = JSONObject.fromObject(queryJson);//			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;			start_data = q_json.has("start_data")?q_json.getString("start_data"):null;			end_data = q_json.has("end_data")?q_json.getString("end_data"):null;			company_code = q_json.has("build_code")?q_json.getString("build_code"):null;			json.put("query", queryJson);		}		Date startData = null;		Date endData = null;		startData=df.parse(start_data);		endData=df.parse(end_data);		int days= getDates(startData,endData)+1;		hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		hhwhere = chkhw(hhwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		hswhere = chkhw(hswhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		hrwhere = chkhw(hrwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		hewhere = chkhw(hewhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		efwhere = chkhw(efwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		efrwhere = chkhw(efrwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		sjwhere = chkhw(sjwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		sjrwhere = chkhw(sjrwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		rturwhere = chkhw(rturwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		dwwhere = chkhw(dwwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		dwsjwhere = chkhw(dwsjwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		dwrtuwhere = chkhw(dwrtuwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		dwefwhere = chkhw(dwefwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		dwvideowhere = chkhw(dwvideowhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";		hswhere = chkhw(hswhere)+"u.id."+fieldname("clzt")+" = "+1+" ";		hewhere = chkhw(hewhere)+"u.id."+fieldname("clzt")+" = "+1+" ";		efwhere = chkhw(efwhere)+"u.id."+fieldname("clzt")+" = "+1+" ";		sjwhere = chkhw(sjwhere)+"u.id."+fieldname("clzt")+" = "+1+" ";		rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("clzt")+" = "+1+" ";		dwwhere = chkhw(dwwhere)+"u.id."+fieldname("dwtype")+" = "+1+" ";		dwsjwhere = chkhw(dwsjwhere)+"( u.id.dwtype = 2 or u.id.dwtype = 5 ) ";		dwrtuwhere = chkhw(dwrtuwhere)+"u.id."+fieldname("dwtype")+" = "+6+" ";		dwefwhere = chkhw(dwefwhere)+"u.id."+fieldname("dwtype")+" = "+7+" ";		dwvideowhere = chkhw(dwvideowhere)+"u.id."+fieldname("dwtype")+" = "+16+" ";		hrwhere = chkhw(hrwhere)+" u.id.data1 = 'U44' ";		hewhere = chkhw(hewhere)+" u.id.data1 = 'U44' ";		efwhere = chkhw(efwhere)+" u.id.data1 = 'EF9' ";		efrwhere = chkhw(efrwhere)+" u.id.data1 = 'EF9' ";		videorwhere = chkhw(videorwhere)+" u.id.data1 = 'EF9' ";		sjwhere = chkhw(sjwhere)+"( u.id.data1 = 'WP4' or u.id.data1 = 'LL4' ) ";		sjrwhere = chkhw(sjrwhere)+"( u.id.data1 = 'WP4' or u.id.data1 = 'LL4' ) ";		rtuwhere = chkhw(rtuwhere)+" u.id.data1 = '44' ";		rturwhere = chkhw(rturwhere)+" u.id.data1 = '44' ";		if(start_data!=null)			hhwhere = chkhw(hhwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    hswhere = chkhw(hswhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    hrwhere = chkhw(hrwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    hewhere = chkhw(hewhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    efwhere = chkhw(efwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    efrwhere = chkhw(efrwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    videorwhere = chkhw(videorwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    sjwhere = chkhw(sjwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    sjrwhere = chkhw(sjrwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		    rturwhere = chkhw(rturwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";		if(end_data!=null)			hhwhere = chkhw(hhwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    hswhere = chkhw(hswhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    hrwhere = chkhw(hrwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    hewhere = chkhw(hewhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    efwhere = chkhw(efwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    efrwhere = chkhw(efrwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    videorwhere = chkhw(videorwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    sjwhere = chkhw(sjwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    sjrwhere = chkhw(sjrwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		    rturwhere = chkhw(rturwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";		int hjtotalCount = ytiotVAlarmDao.getHJCount(hhwhere);		int clhjtotalCount = ytiotVAlarmDao.getHJCount(hswhere);		int lxhjtotalCount = ytiotVAlarmDao.getHJCount(hrwhere);		int cllxhjtotalCount = ytiotVAlarmDao.getHJCount(hewhere);		int eftotalCount = ytiotVAlarmDao.getEFireCount(hhwhere);		int cleftotalCount = ytiotVAlarmDao.getEFireCount(hswhere);		int lxeftotalCount = ytiotVAlarmDao.getEFireCount(efrwhere);		int cllxeftotalCount = ytiotVAlarmDao.getEFireCount(efwhere);		int sjtotalCount = ytiotVAlarmDao.getSJCount(hhwhere);		int clsjtotalCount = ytiotVAlarmDao.getSJCount(hswhere);		int lxsjtotalCount = ytiotVAlarmDao.getSJCount(sjrwhere);		int cllxsjtotalCount = ytiotVAlarmDao.getSJCount(sjwhere);		int rtutotalCount = ytiotVAlarmDao.getRTUCount(hhwhere);		int clrtutotalCount = ytiotVAlarmDao.getRTUCount(hswhere);		int lxrtutotalCount = ytiotVAlarmDao.getRTUCount(rturwhere);		int cllxrtutotalCount = ytiotVAlarmDao.getRTUCount(rtuwhere);		int dwhjtotalCount = ytiotVDataDao.getSyncStatusCount1(dwwhere);		int dwsjtotalCount = ytiotVDataDao.getSyncStatusCount1(dwsjwhere);		int dwrtutotalCount = ytiotVDataDao.getSyncStatusCount1(dwrtuwhere);		int dweftotalCount = ytiotVDataDao.getSyncStatusCount1(dwefwhere);		int dwvideototalCount = ytiotVDataDao.getSyncStatusCount1(dwvideowhere);		int videototalCount = ytiotVAlarmDao.getCount("ytiot_v_video2017",hhwhere);		int clvideototalCount = ytiotVAlarmDao.getCount("ytiot_v_video2017",hswhere);		NumberFormat numberFormat = NumberFormat.getInstance();		numberFormat.setMaximumFractionDigits(2);		if(hjtotalCount==0) {			String result = "100";			json.put("hjbaifenbi", result);		}else {			String result = numberFormat.format((float)clhjtotalCount/(float)hjtotalCount*100);			json.put("hjbaifenbi", result);//			int clhjbaifenbi = Integer.parseInt( result );//			json.put("clhjbaifenbi", clhjbaifenbi);		}		if(lxhjtotalCount==0) {			String result = "100"+"%";			json.put("lxhjbaifenbi", result);		}else {			String result = numberFormat.format((float)cllxhjtotalCount/(float)lxhjtotalCount*100);			json.put("lxhjbaifenbi", result+"%");		}		if(eftotalCount==0) {			String result = "100";			json.put("efbaifenbi", result);		}else {			String result = numberFormat.format((float)cleftotalCount/(float)eftotalCount*100);			json.put("efbaifenbi", result);		}		if(lxeftotalCount==0) {			String result = "100"+"%";			json.put("lxefbaifenbi", result);		}else {			String result = numberFormat.format((float)cllxeftotalCount/(float)lxeftotalCount*100);			json.put("lxefbaifenbi", result+"%");		}		if(videototalCount==0) {			String result = "100";			json.put("videobaifenbi", result);		}else {			String result = numberFormat.format((float)clvideototalCount/(float)videototalCount*100);			json.put("videobaifenbi", result);		}		if(sjtotalCount==0) {			String result = "100";			json.put("sjbaifenbi", result);		}else {			String result = numberFormat.format((float)clsjtotalCount/(float)sjtotalCount*100);			json.put("sjbaifenbi", result);		}		if(lxsjtotalCount==0) {			String result = "100"+"%";			json.put("lxsjbaifenbi", result);		}else {			String result = numberFormat.format((float)cllxsjtotalCount/(float)lxsjtotalCount*100);			json.put("lxsjbaifenbi", result+"%");		}		if(rtutotalCount==0) {			String result = "100";			json.put("rtubaifenbi", result);		}else {			String result = numberFormat.format((float)clrtutotalCount/(float)rtutotalCount*100);			json.put("rtubaifenbi", result);		}		if(lxrtutotalCount==0) {			String result = "100"+"%";			json.put("lxrtubaifenbi", result);		}else {			String result = numberFormat.format((float)cllxrtutotalCount/(float)lxrtutotalCount*100);			json.put("lxrtubaifenbi", result+"%");		}		if(dwhjtotalCount==0) {			hjresult = "0";			lxhjresult = "0";		}else {			hjresult = numberFormat.format((float)hjtotalCount/(float)days/(float)dwhjtotalCount);			lxhjresult = numberFormat.format((float)lxhjtotalCount/(float)days/(float)dwhjtotalCount);		}		if(dwsjtotalCount==0) {			sjresult = "0";			lxsjresult = "0";		}else {			sjresult = numberFormat.format((float)sjtotalCount/(float)days/(float)dwsjtotalCount);			lxsjresult = numberFormat.format((float)lxsjtotalCount/(float)days/(float)dwsjtotalCount);		}		if(dwrtutotalCount==0) {			rturesult = "0";			lxrturesult = "0";		}else {			rturesult = numberFormat.format((float)rtutotalCount/(float)days/(float)dwrtutotalCount);			lxrturesult = numberFormat.format((float)lxrtutotalCount/(float)days/(float)dwrtutotalCount);		}		if(dweftotalCount==0) {			efresult = "0";			lxefresult = "0";		}else {			efresult = numberFormat.format((float)eftotalCount/(float)days/(float)dweftotalCount);			lxefresult = numberFormat.format((float)lxeftotalCount/(float)days/(float)dweftotalCount);		}		if(dwvideototalCount==0) {			videoresult = "0";		}else {			videoresult = numberFormat.format((float)videototalCount/(float)days/(float)dwvideototalCount);		}   		int hjsjrtuCount = hjtotalCount+sjtotalCount+rtutotalCount+eftotalCount+videototalCount;		String result1 = numberFormat.format((float)hjtotalCount/(float)hjsjrtuCount*100);		String result2 = numberFormat.format((float)sjtotalCount/(float)hjsjrtuCount*100);		String result3 = numberFormat.format((float)rtutotalCount/(float)hjsjrtuCount*100);		String result4 = numberFormat.format((float)eftotalCount/(float)hjsjrtuCount*100);		String result5 = numberFormat.format((float)videototalCount/(float)hjsjrtuCount*100);		Map map4 = new HashMap();		map4.put("lxhjresult", lxhjresult);		map4.put("lxsjresult", lxsjresult);		map4.put("lxrturesult", lxrturesult);		map4.put("lxefresult", lxefresult);		map4.put("efresult", efresult);		map4.put("videoresult", videoresult);		map4.put("dweftotalCount", dweftotalCount);		map4.put("dwvideototalCount", dwvideototalCount);		map4.put("eftotalCount", eftotalCount);		map4.put("cleftotalCount", cleftotalCount);		map4.put("lxeftotalCount", lxeftotalCount);		map4.put("cllxeftotalCount", cllxeftotalCount);		map4.put("videototalCount", videototalCount);		map4.put("clvideototalCount", clvideototalCount);		map4.put("result1", result1);		map4.put("result2", result2);		map4.put("result3", result3);		map4.put("result4", result4);		map4.put("result5", result5);//		map.put("xmlx", g.getXmlx());		JSONObject jSONObject4 = JSONObject.fromObject(map4);		jSONArray4.add(jSONObject4);		json.put("RESULT4", jSONArray4);		json.put("hjtotalCount", hjtotalCount);		json.put("clhjtotalCount", clhjtotalCount);		json.put("lxhjtotalCount", lxhjtotalCount);		json.put("cllxhjtotalCount", cllxhjtotalCount);		json.put("sjtotalCount", sjtotalCount);		json.put("clsjtotalCount", clsjtotalCount);		json.put("lxsjtotalCount", lxsjtotalCount);		json.put("cllxsjtotalCount", cllxsjtotalCount);		json.put("rtutotalCount", rtutotalCount);		json.put("clrtutotalCount", clrtutotalCount);		json.put("lxrtutotalCount", lxrtutotalCount);		json.put("cllxrtutotalCount", cllxrtutotalCount);		json.put("dwhjtotalCount", dwhjtotalCount);		json.put("dwsjtotalCount", dwsjtotalCount);		json.put("dwrtutotalCount", dwrtutotalCount);		json.put("days", days);		json.put("hjresult", hjresult);		json.put("sjresult", sjresult);		json.put("rturesult", rturesult);			List list = ytiotVCompanyDao.query1(hqlwhere, null, null, null, null);			List list1 = ytiotVCompanyDao.query2(hqlwhere, null, null, null, null);			List list2 = ytiotVCompanyDao.query3(hqlwhere, null, null, null, null);			List list3 = ytiotVAlarmDao.HJQuery(hswhere, null, null, null, null);			List list4 = ytiotVAlarmDao.SJQuery(hswhere, null, null, null, null);			List list5 = ytiotVAlarmDao.RTUQuery(hswhere, null, null, null, null);						if(list.size()>0) {				for(int i=0;i<list.size();i++) {					YtiotTProjectDetails g = (YtiotTProjectDetails)list.get(0);//					YtiotVCompanyId Id = o.getId();					Map map = new HashMap();					map.put("company_name", g.getCompanyName()==null?"":g.getCompanyName());					map.put("approach_time",g.getApproachTime()==null?"":df.format(g.getApproachTime()));					map.put("complete_time",g.getCompleteTime()==null?"":df.format(g.getCompleteTime()));					map.put("check_time", g.getCheckTime()==null?"":df.format(g.getCheckTime()));//					map.put("xmlx", g.getXmlx());					JSONObject jSONObject = JSONObject.fromObject(map);					jSONArray.add(jSONObject);					json.put("RESULT", jSONArray);				}							}			if(list1.size()>0) {				int device_num=0;				for(int i=0;i<list1.size();i++) {					YtiotTProjectDevice o = (YtiotTProjectDevice)list1.get(i);					device_num+=o.getDeviceNum();//					YtiotVCompanyId Id = o.getId();					Map map1 = new HashMap();					map1.put("device_name", o.getDeviceName()==null?"":o.getDeviceName());					map1.put("specifications", o.getSpecifications()==null?"":o.getSpecifications());					map1.put("device_num", o.getDeviceNum()==0?"":o.getDeviceNum());					map1.put("data_info", o.getDataInfo()==null?"":o.getDataInfo());					JSONObject jSONObject1 = JSONObject.fromObject(map1);					jSONArray1.add(jSONObject1);					json.put("RESULT1", jSONArray1);					if(o.getDataInfo()!=null && o.getDataInfo().equals("efire")) {						device_type="efire";					}else if(o.getDataInfo()!=null && o.getDataInfo().equals("video")) {						video_type="video";					}				}				json.put("device_type", device_type);				json.put("device_num1", device_num);			}//			if(device_type.equals("efire")) {//				List list6 = ytiotVAlarmDao.EFireQuery(hswhere, null, null, null, null);//				//			}			if(list2.size()>0) {				int device_num2=0;				for(int i=0;i<list2.size();i++) {					YtiotTProjectMonitor h = (YtiotTProjectMonitor)list2.get(i);					device_num2+=h.getMonitorSum();//					YtiotVCompanyId Id = o.getId();					Map map2 = new HashMap();					map2.put("monitor_son", h.getMonitorSon()==null?"":h.getMonitorSon());					map2.put("monitor_type", h.getMonitorType()==null?"":h.getMonitorType());					map2.put("monitor_sum", h.getMonitorSum()==0?"":h.getMonitorSum());					map2.put("data_info", h.getDataInfo()==null?"":h.getDataInfo());					JSONObject jSONObject2 = JSONObject.fromObject(map2);					jSONArray2.add(jSONObject2);					json.put("RESULT2", jSONArray2);				}				json.put("device_num2", device_num2);			}			if(list3.size()>0) {				for(int i=0;i<list3.size();i++) {					YtiotVHj z = (YtiotVHj)list3.get(0);					YtiotVHjId id = z.getId();					Date d1=id.getTime();					Date d2=id.getClsj();					long diff = d2.getTime() - d1.getTime();					long days1 = diff / (1000 * 60 * 60 * 24);					days2 += days1;					m+=1;									}				String days3= numberFormat.format((float)days2/(float)m);				json.put("days3", days3);			}else {				json.put("days3", "0");			}			if(list4.size()>0) {				for(int i=0;i<list4.size();i++) {					YtiotVSj s = (YtiotVSj)list4.get(0);					YtiotVSjId id1 = s.getId();					Date d1=id1.getTime();					Date d2=id1.getClsj();					long diff = d2.getTime() - d1.getTime();					long days4 = diff / (1000 * 60 * 60 * 24);					days5 += days4;					q+=1;									}								String days6= numberFormat.format((float)days5/(float)q);				json.put("days6", days6);			}else {				json.put("days6", "0");			}			if(list5.size()>0) {				for(int i=0;i<list5.size();i++) {					YtiotVRtu s = (YtiotVRtu)list5.get(0);					YtiotVRtuId id1 = s.getId();					Date d1=id1.getTime();					Date d2=id1.getClsj();					long diff = d2.getTime() - d1.getTime();					long days7 = diff / (1000 * 60 * 60 * 24);					days8 += days7;					x+=1;									}								String days9= numberFormat.format((float)days8/(float)x);				json.put("days9", days9);			}else {				json.put("days9", "0");			}		return json.toString();	}
 |