Chinaunix首页 | 论坛 | 博客
  • 博客访问: 189303
  • 博文数量: 92
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1413
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-04 21:12
文章分类
文章存档

2013年(92)

我的朋友

分类: 信息化

2013-05-18 02:45:53

1.?[代码][Java]代码???? 跳至 [1] [全屏预览] /**
 * 
 * @author luyl
 * luyllyl@gmail.com
 */
public class OrbitInfo {
	
	private String id;
	。。。。
	private String dayOrNight;
	private String taskType;
        //  开始的时候此处是private int isDelte;同时把get\set也改过来。
	private Integer isDelete;
	private Long lastModified;
	private Date createTime;
	private Long fileSize;
	private Float resolution;
	
	//...get\set方法,开始时代码
	//public void setIsDelete(int isDelete) {
	//	this.isDelete = isDelete;
	//}

	//public int getIsDelete() {
	//	return isDelete;
	//}
	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}

	public Integer getIsDelete() {
		return isDelete;
	}
}
//后台logic类要调用的方法
@SuppressWarnings("unchecked")
	public Map listOrbit(int currentPage, int pageSize, Map map) {
		
		HttpSession session =WebContextFactory.get().getSession(false);
		List ids = (List)session.getAttribute("ids");
		String key = (String)session.getAttribute("key");
		
		StringBuilder sb = new StringBuilder("select {o.*}, {p.*}  from t_mas_orbit_info o join t_mas_projection_info p on o.id=p.orbitid ");
		if(ids!=null){
			sb.append(" join T_MAS_META_TEMP m on p.id = m.valueid ");
		}
		
		sb.append(" where 1=1 ");
		
		if(ids!=null){
			sb.append(" and m.k ='"+ key +"' ");
		}
		
		String satellite=map.get("satellite").toString();
		String sensor= map.get("sensor").toString();
		String dayOrNight = map.get("dayOrNight").toString();
		String resolution = "";
		
		Object rr = map.get("resolution");
		resolution=Float.toString(Float.valueOf(""+rr).floatValue() / 100000);
		
		String stime = map.get("beginTime").toString();
		String etime = map.get("endTime").toString();
		
		
		
		if(!StringUtils.isEmpty(satellite)){
			sb.append(" and o.satellite='"+satellite+"' ");
		}
		if(!StringUtils.isEmpty(sensor)){
			sb.append(" and o.sensor='"+sensor+"' ");
		}
		if(!StringUtils.isEmpty(dayOrNight)){
			sb.append(" and o.dayornight='"+dayOrNight+"' ");
		}
		if(!StringUtils.isEmpty(resolution)){
			sb.append(" and p.resolutionx='"+resolution+"' ");
		}
		if(!StringUtils.isEmpty(stime)){
			stime = stime.replaceAll("-|:|\\s", "");
			sb.append(" and o.observationdate >= '"+ stime + "' ");
		}
		if(!StringUtils.isEmpty(etime)){
			etime = etime.replaceAll("-|:|\\s", "");
			sb.append(" and o.observationdate <= '"+ etime + "' ");
		}
		sb.append("  and p.thumbnail is not null ");

		return orbitInfoDAO.orbitPage(currentPage, pageSize, sb.toString());
	}


Dao类对应的方法:
	public Map orbitPage(int currentPage, int pageSize, String nativeSql){
		List list = (List)getSession().createSQLQuery(nativeSql)
					.addEntity("o",OrbitInfo.class)
					.addEntity("p", ProjectionInfo.class)
		            .setFirstResult((currentPage-1)*pageSize)
		            .setMaxResults(pageSize)
		            .list();
		//得到总记录数:
		String countSql = "select count(*) as total "+nativeSql.substring(nativeSql.indexOf("from"));
		Double total= (Double)getSession().createSQLQuery(countSql).addScalar("total", Hibernate.DOUBLE).uniqueResult();
		Map m = new HashMap(2);
		m.put("all", total.intValue());
		m.put("list", list);
		return m;
	}  
阅读(854) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~