@RequestMapping(params = "datagrid")
public void datagrid(PickingBillEntitypickingBill,HttpServletRequest request, HttpServletResponse response, DataGriddataGrid) {
Map<String, String[]> reqMap = request.getParameterMap();
String plateNumber = request.getParameter("car.plateNumber");
if(StringUtil.isNotEmpty(plateNumber)){
//模糊查询
// List<CarEntity> carList =this.systemService.findByProperty(CarEntity.class, "plateNumber",plateNumber);
List<Map<String, Object>> v_list_carId= this.systemService.findForJdbc("SELECT idFROM car WHERE plate_number LIKE '%"+plateNumber+"%'",null);
String v_carId = "";
if(v_list_carId !=null && v_list_carId.size()>0){
v_carId =(String) v_list_carId.get(0).get("id");
pickingBill.setCarId(v_carId);
pickingBill.setCar(new CarEntity());
}else{
pickingBill.setCarId(v_carId);
pickingBill.setCar(new CarEntity());
}
}
CriteriaQuery cq = new CriteriaQuery(PickingBillEntity.class, dataGrid);
//查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq,pickingBill, reqMap);
this.pickingBillService.getDataGridReturn(cq,true);
//获取车辆信息
List<PickingBillEntity> sendcarList = dataGrid.getResults();
for (PickingBillEntity item : sendcarList)
{
if(!StringUtil.isEmpty(item.getCarId()))
{
CarEntity v_car = this.systemService.getEntity(CarEntity.class, item.getCarId());
item.setCar(v_car);
}
}
TagUtil.datagrid(response, dataGrid);
}
如图中红线所示,如果该 v_carId=”” 注意这里是没有空格的,有空格情况为 v_carId=” ”
差距不明显,如果是第一种情况,在else块中
然后进入组装查询
Impl 的值
也就是说根据实体去查询所有的列。最终结果还是显示所有
如果 将 v_carId换成了带空格的形式。Debug看结果
发现与之前的情况不同的是,它根据carId 为空去查找。得到的就是我们想要的结果了。即是: