action
定义一个 HashMap,将参数放到里面
private void doSelect(){
HashMap<String,Object> param = new HashMap<String,Object> ();
//工贸
param.put("trade", trade);
//门店
param.put("store", store);
//产品代表
param.put("productDuty", productDuty);
//产品型号
param.put("product", product);
//开始时间
param.put("startDate", manchineJson.getStartDate());
//结束时间
param.put("endDate", manchineJson.getEndDate());
try{
manchineOpenedJsonList=manchineOpenedManager.getManchineOpenedJsonList(reportPage,param);
if (manchineOpenedJsonList!=null && manchineOpenedJsonList.size()>0){
manchineJson=manchineOpenedJsonList.get(0);
}
}catch(Exception e){
e.printStackTrace();
}
}
dao层实现
/**
* 获取工贸-门店-产品代表-型号
*/
public List<ManchineOpenedJson> getManchineOpenedJsonList(Page reportPage,HashMap<String, Object> param) {
// TODO Auto-generated method stub
Session session=this.getSessionFactory().openSession();
//工贸
String trade = (String)param.get("trade");
//门店
String store = (String)param.get("store");
//产品代表
String productDuty = (String)param.get("productDuty");
//产品型号
String product = (String)param.get("product");
//开始时间
String startDate = (String)param.get("startDate");
//结束时间
String endDate = (String)param.get("endDate");
String queryHql = "";
//查询条件
if(trade != null && !"".equals(trade) && !"null".equals(trade)){
queryHql += "and tradeognm='" + trade + "'";
}
if(store != null && !"".equals(store) && !"null".equals(store)){
queryHql += " and custnm='" + store + "'";
}
if(productDuty != null && !"".equals(productDuty) && !"null".equals(productDuty)){
queryHql += " and productdutyempnm='" + productDuty + "'";
}
if(product != null && !"".equals(product) && !"null".equals(product)){
queryHql+= " and productnm='" + product + "'";
}
if(startDate != null && !"".equals(startDate) && !"null".equals(startDate)){
queryHql += " and c.activ_time >='" + startDate + "'";
}
if(endDate != null && !"".equals(endDate) && !"null".equals(endDate)){
queryHql += " and c.activ_time <='" + endDate + "'";
}
return list;
}