📄 traffichotspotqueryprocess.java
字号:
package com.statistical.process;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.map.LinkedMap;
import com.statistical.StaticInfo;
import com.statistical.tools.DateUtils;
public class TrafficHotspotQueryProcess implements IStatisticalProcessIntf {
public boolean process(HttpServletRequest request,
HttpServletResponse response) throws Exception {
System.out.println("start111 here");
String queryType = request.getParameter("queryType");
String startLimit = request.getParameter("startLimit");
String endLimit = request.getParameter("endLimit");
String hotspotArea = request.getParameter("hotspotArea");
List<String> areaList = null;
Map<String,List> resultMap = new LinkedMap();//key = datetime
if("".equals(hotspotArea)){
areaList = StaticInfo.areas;
}else{
areaList = new ArrayList<String>();
areaList.add(hotspotArea);
}
String dateCondition = null;
String datePartStr = null;
if(queryType.equals(StaticInfo.QUERY_TYPE_YEAR)){
dateCondition = DateUtils.getYearsString(startLimit, endLimit);
//test by fxd
System.out.println(dateCondition);
//datePartStr = "substr(LOC_TIME,0,4)";
//datePartStr = "substr(TMNL_TIME,0,4)";
}
if(queryType.equals(StaticInfo.QUERY_TYPE_MONTH)){
dateCondition = DateUtils.getMonthsString(startLimit, endLimit);
//datePartStr = "substr(LOC_TIME,0,7)";
datePartStr = "substr(TMNL_TIME,0,7)";
}
if(queryType.equals(StaticInfo.QUERY_TYPE_DAY)){
dateCondition = DateUtils.getDaysString(startLimit, endLimit);
//datePartStr = "LOC_TIME";
datePartStr = "TMNL_TIME";
}
for(int i=0;i<areaList.size();i++){
//String sql = "select count(distinct TMNL_ID) as count,datepart(year,LOC_TIME) as dateStr from "+StaticInfo.TATISTICAL_TABLE_NAME+" where LOC_DESC like '%"+areaList.get(i)+"%' and datepart(year,LOC_TIME) in "+yearCondition+" group by datepart(year,LOC_TIME)";
//String sql ="select count(distinct TMNL_ID) as count,"+datePartStr+" as dateStr from "+StaticInfo.TATISTICAL_TABLE_NAME+" where LOC_DESC like '%"+areaList.get(i)+"%' and "+datePartStr+" in "+dateCondition+" group by "+datePartStr+" order by "+datePartStr;
String sql ="select t.TMNL_NUM as count,"+datePartStr+" as dateStr from ASC_ARER_TMNL_TBL t where LOC_DESC like '%"+areaList.get(i)+"%' and "+datePartStr+" in "+dateCondition+" group by "+datePartStr+" order by "+datePartStr;
List<Map<String, String>> lt = command.executeSql(sql);
for(int resultCount = 0;resultCount<lt.size();resultCount++){
Map<String, String> map = lt.get(resultCount);
String dateTime = map.get("dateStr".toUpperCase());
String count = map.get("count".toUpperCase());
if(resultMap.containsKey(dateTime)){
List tmpLt = resultMap.get(dateTime);
tmpLt.add(count);
}else{
List tmpLt = new ArrayList();
tmpLt.add(count);
resultMap.put(dateTime,tmpLt);
}
}
}
Iterator iter = resultMap.keySet().iterator();
while(iter.hasNext()){
List lt = resultMap.get(iter.next());
if(lt.size()<areaList.size()){
Integer size =areaList.size()-lt.size();
for(int i=0;i<size;i++){
lt.add(" ");
}
}
}
request.setAttribute("titleList", areaList);
request.setAttribute("resultMap", resultMap);
command.doWithConnection();
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -