Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. /// class AccountGeo
  2. public class AccountGeo{
  3.     String id;
  4.     IFacilitiesGeoConfig geoParam;
  5.  
  6.     public AccountGeo() {
  7.     }
  8.  
  9.     public AccountGeo(String id, IFacilitiesGeoConfig geoParam) {
  10.         this.id = id;
  11.         this.geoParam = geoParam;
  12.     }
  13.  
  14.     public String getId() {
  15.         return id;
  16.     }
  17.  
  18.     public void setId(String id) {
  19.         this.id = id;
  20.     }
  21.  
  22.     public IFacilitiesGeoConfig getGeoParam() {
  23.         return geoParam;
  24.     }
  25.  
  26.     public void setGeoParam(IFacilitiesGeoConfig geoParam) {
  27.         this.geoParam = geoParam;
  28.     }
  29.  
  30.     @Override
  31.     public String toString() {
  32.         return "AccountGeo{" +
  33.                 "id='" + id + '\'' +
  34.                 ", geoParam=" + geoParam +
  35.                 '}';
  36.     }
  37. }
  38.  
  39. //accountDbservice
  40. public List<AccountGeo> getAccountGeosByAccountIds(String[] accountIds) {
  41.  
  42.         List<AccountGeo> accountGeos = new ArrayList<>();
  43.         try {
  44.             accountGeos = jdbcTemplate.query("SELECT id, MALatitude__c, MALongitude__c FROM batch.ACCOUNT where id in ('" + String.join("','", accountIds) + "')", (rs, rowNum) -> {
  45.                 IFacilitiesGeoConfig geo = new IFacilitiesGeoConfig();
  46.                 geo.setLatitude(rs.getDouble("MALatitude__c"));
  47.                 geo.setLongitude(rs.getDouble("MALongitude__c"));
  48.  
  49.                 AccountGeo accountGeo = new AccountGeo();
  50.                 accountGeo.setGeoParam(geo);
  51.                 accountGeo.setId(rs.getString("id"));
  52.                 return accountGeo;
  53.             });
  54.  
  55.             LOGGER.info(String.format("Select form database - ok"));
  56.  
  57.         } catch (DataAccessException e) {
  58.             LOGGER.error(String.format("Error occurred when fetching accounts from database: %s", e.getMessage()));
  59.         }
  60.         return accountGeos;
  61.  
  62.     }
  63.  
  64. //accountcontroller
  65.     @PostMapping(value = "accGeos")
  66.     List<AccountGeo> findAccountWithGeos(@RequestBody String[] ids) {
  67.         return accountDBService.getAccountGeosByAccountIds(ids);
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement