//查询该区内所有用户的轨迹数据
public IBean DrawTrackInMap(){
HttpServletRequest request=Request.getInst();
String type =request.getParameter("type");
String userarea =request.getParameter("userarea");
String trackdate =request.getParameter("trackdate");
String sqlStr =" Select sd.userid ,sd.intime,sd.xpoint,sd.ypoint ,su.user_name from P_CollectionData sd ,SY_USER su where 1=1 ";
if(! type.equals("-1")){
sqlStr +=" and sd.typeid ='"+type+"'";
}
sqlStr +=" and to_char(sd.trackdate,'yyyy-mm-dd') ='"+trackdate+"'"
+" and sd.userid =su.user_code and sd.userid in (select a.userid from Track_UserArea_Tb a where a.userarea ='"+userarea+"') "
+" group by sd.userid, sd.intime,sd.xpoint,sd.ypoint ,su.user_name"
+" order by sd.userid , sd.intime ";
ISqlExecutor isql=SqlUtil .getExecutor();
List<IBean> ibeanList = isql.query(sqlStr);
List<ClsTrackJson> JSLIST = dataChuliJson3(ibeanList);
IBean iBean=new Bean();
iBean.set("guiji", JSLIST);
return iBean;
}
//处理成轨迹json分段
public List<ClsTrackJson> dataChuliJson3(List<IBean> ibeanList){List<ClsTrackJson> cjsonList =new ArrayList<ClsTrackJson>();
List<Map<String, String>> mapList = new ArrayList<Map<String,String>>();
Map<String, String> mapJson = null;
ClsTrackJson clsTrackJson = null;
int i=0;
for (IBean list : ibeanList){
if(i==0){
IBean iBean1 =ibeanList.get(i);
clsTrackJson =new ClsTrackJson();
clsTrackJson.set_BeginTime(String.valueOf(iBean1.get("INTIME")));
mapJson =new HashMap<String, String>();
mapJson.put("XPOINT", String.valueOf(iBean1.get("XPOINT")));
mapJson.put("YPOINT", String.valueOf(iBean1.get("YPOINT")));
mapJson.put("INTIME", String.valueOf(iBean1.get("INTIME")));
mapList.add(mapJson);
}else{
IBean iBean0 =ibeanList.get(i-1);
IBean iBean1 =ibeanList.get(i);
if(! timeBijiao(String.valueOf(iBean0.get("INTIME")),String.valueOf(iBean1.get("INTIME")))
&& String.valueOf(iBean0.get("USERID")).equals(String.valueOf(iBean1.get("USERID"))) ){
mapJson =new HashMap<String, String>();
mapJson.put("XPOINT", String.valueOf(iBean1.get("XPOINT")));
mapJson.put("YPOINT", String.valueOf(iBean1.get("YPOINT")));
mapJson.put("INTIME", String.valueOf(iBean1.get("INTIME")));
mapList.add(mapJson);
if(i ==ibeanList.size()-1){
clsTrackJson.set_EndTime(String.valueOf(iBean0.get("INTIME")));
clsTrackJson.set_JsonPts(new JSONArray().fromObject(mapList));
mapList.clear();
clsTrackJson.set_UserFullName(String.valueOf(iBean0.get("USER_NAME")));
cjsonList.add(clsTrackJson);
}
}else{
clsTrackJson.set_EndTime(String.valueOf(iBean0.get("INTIME")));
clsTrackJson.set_UserFullName(String.valueOf(iBean0.get("USER_NAME")));
clsTrackJson.set_JsonPts(new JSONArray().fromObject(mapList));
cjsonList.add(clsTrackJson);
mapList.clear();
mapJson.clear();
mapJson =new HashMap<String, String>();
mapJson.put("XPOINT", String.valueOf(iBean1.get("XPOINT")));
mapJson.put("YPOINT", String.valueOf(iBean1.get("YPOINT")));
mapJson.put("INTIME", String.valueOf(iBean1.get("INTIME")));
mapList.add(mapJson);
clsTrackJson =new ClsTrackJson();
clsTrackJson.set_BeginTime(String.valueOf(iBean1.get("INTIME")));
}
}
i++;
}
return cjsonList;
}