Advertisement
TriplePi

Untitled

Jun 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. public String getChecksForDashboard(Integer templateId, Integer shopId, JdbcTemplate jdbcPool){
  2.         String getChecksForDashboardSql =
  3.                 " SELECT c.ID AS checklistId, c.GRADE AS checklistGrade,c.FINISH_DATE AS finishDate " +
  4.                 " FROM T_CHECKLIST c " +
  5.                 " WHERE c.TEMPLATE_ID=? AND c.SHOP_ID=? AND c.FINISH_DATE > (CURRENT_DATE - 365) " +
  6.                 " ORDER BY c.FINISH_DATE DESC ";
  7.  
  8.         List<CheckForDashboard> checkForDashboardList = jdbcPool.query(getChecksForDashboardSql,new Object[]{templateId,shopId},new RowMapper<CheckForDashboard>() {
  9.             @Override
  10.             public CheckForDashboard mapRow(ResultSet rs, int rowNum) throws SQLException {
  11.                 CheckForDashboard result = new CheckForDashboard();
  12.                 result.setCheklistId(rs.getInt("checklistid"));
  13.                 result.setCheklistGrade(rs.getFloat("cheklistgrade"));
  14.                 result.setFinishDate(rs.getDate("finishdate"));
  15.                 return result;
  16.             }
  17.         });
  18.  
  19.         StringWriter stringWriter = new StringWriter();
  20.         ObjectMapper mapper = new ObjectMapper();
  21.  
  22.         try {
  23.             mapper.writeValue(stringWriter,checkForDashboardList);
  24.         } catch (IOException e) {
  25.             e.printStackTrace();
  26.         }
  27.  
  28.         return stringWriter.toString();
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement