@RequestMapping(params = "list") public ModelAndView list(HttpServletRequest request) { List<Map<String,Object>> list = new ArrayList<>(); for(int i=1;i<13;i++){ Map<String,Object> m = new HashMap<>(); m.put("orderNum",i); m.put("orderName",i+"月"); list.add(m); } request.setAttribute("nameLists",list); return new ModelAndView("com/jeecg/logisticsforecast/logisticsForecastList"); }
@RequestMapping(params = "datagrid") public void datagrid(LogisticsForecastEntity logisticsForecast, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { CriteriaQuery cq = new CriteriaQuery(LogisticsForecastEntity.class, dataGrid); //查询条件组装器 org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, logisticsForecast, request.getParameterMap()); String sql = ""; try { //自定义追加查询条件 sql = " select * from logistics_forecast\n" + " group by for_Import_Batch,for_Category,for_Crade "; RowMapper<LogisticsForecastEntity> rowMapper1=new BeanPropertyRowMapper<LogisticsForecastEntity>(LogisticsForecastEntity.class); List<LogisticsForecastEntity> ruleList= jdbcTemplate.query(sql, rowMapper1); dataGrid.setTotal(ruleList.size()); dataGrid.setResults(ruleList); } catch (Exception e) { throw new BusinessException(e.getMessage()); } /* cq.add(); this.logisticsForecastService.getDataGridReturn(cq, true);*/ List<LogisticsForecastEntity> list = dataGrid.getResults(); Map<String, Map<String, Object>> extMap = new HashMap<String, Map<String, Object>>(); for (LogisticsForecastEntity temp : list) { Map m = new HashMap(); sql = " select right(forecast_date,2) forecastDate, forecast_qty forecastQty " + " from logistics_forecast\n" + " where for_Import_Batch = '"+temp.getForImportBatch()+"' " + " and for_Category = '"+temp.getForCategory()+"' "+ " and for_Crade = '"+temp.getForCrade()+"' "; List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql); for (int i = 0; i <list1.size(); i++) { Map<String, Object> map = list1.get(i); int num = i + 1; String month = formateMM(String.valueOf(i+1)); String forecastDate = ""; // 月份 String forecastQty = "0"; // 数量 if(StringUtil.isNotEmpty(map.get("forecastDate"))){ forecastDate = String.valueOf(map.get("forecastDate")); if(forecastDate.equals(month)){ if(StringUtil.isNotEmpty(map.get("forecastQty"))){ forecastQty =String.valueOf(map.get("forecastQty")); } } } m.put("forecastQty"+num,forecastQty); } extMap.put(temp.getId(), m); } TagUtil.datagrid(response, dataGrid,extMap); }
private String formateMM(String res) { int length = res.length(); if (length == 1) { res = "0" + res; } return res; }
<%-- 列表页面 --%>
<c:forEach items="${nameLists}" var="poVal" varStatus="stuts"> <t:dgCol title="${poVal.orderName }" field="forecastQty${poVal.orderNum }" queryMode="single" width="90" extendParams="styler:fmtype1" ></t:dgCol> </c:forEach>
效果
标签:String,备份,list,forecastDate,dataGrid,转列,new,forecastQty,jeecg From: https://www.cnblogs.com/xueblvip/p/18386801