List of usage examples for io.vertx.core.json JsonObject getValue
public Object getValue(String key)
From source file:com.funmix.entity.DriverConverter.java
License:Apache License
public static void fromJson(JsonObject json, Driver obj) { if (json.getValue("created_time") instanceof String) { obj.setCreated_time((String) json.getValue("created_time")); }/* w w w . j a v a 2 s . co m*/ if (json.getValue("driverlicense") instanceof String) { obj.setDriverlicense((String) json.getValue("driverlicense")); } if (json.getValue("email") instanceof String) { obj.setEmail((String) json.getValue("email")); } if (json.getValue("id") instanceof Number) { obj.setId(((Number) json.getValue("id")).intValue()); } if (json.getValue("memo") instanceof String) { obj.setMemo((String) json.getValue("memo")); } if (json.getValue("phone") instanceof String) { obj.setPhone((String) json.getValue("phone")); } if (json.getValue("status") instanceof Number) { obj.setStatus(((Number) json.getValue("status")).intValue()); } if (json.getValue("username") instanceof String) { obj.setUsername((String) json.getValue("username")); } }
From source file:com.funmix.entity.LineConverter.java
License:Apache License
public static void fromJson(JsonObject json, Line obj) { if (json.getValue("drivername") instanceof String) { obj.setDrivername((String) json.getValue("drivername")); }// w ww .j ava2 s . c o m if (json.getValue("endaddr") instanceof String) { obj.setEndaddr((String) json.getValue("endaddr")); } if (json.getValue("endtime") instanceof String) { obj.setEndtime((String) json.getValue("endtime")); } if (json.getValue("id") instanceof Number) { obj.setId(((Number) json.getValue("id")).intValue()); } if (json.getValue("licenseplate") instanceof String) { obj.setLicenseplate((String) json.getValue("licenseplate")); } if (json.getValue("linename") instanceof String) { obj.setLinename((String) json.getValue("linename")); } if (json.getValue("path") instanceof String) { obj.setPath((String) json.getValue("path")); } if (json.getValue("process") instanceof Number) { obj.setProcess(((Number) json.getValue("process")).intValue()); } if (json.getValue("startaddr") instanceof String) { obj.setStartaddr((String) json.getValue("startaddr")); } if (json.getValue("starttime") instanceof String) { obj.setStarttime((String) json.getValue("starttime")); } if (json.getValue("status") instanceof Number) { obj.setStatus(((Number) json.getValue("status")).intValue()); } }
From source file:com.funmix.entity.OrderConverter.java
License:Apache License
public static void fromJson(JsonObject json, Order obj) { if (json.getValue("abnormal") instanceof Number) { obj.setAbnormal(((Number) json.getValue("abnormal")).intValue()); }/*from w w w . ja va 2s.c o m*/ if (json.getValue("attachment") instanceof String) { obj.setAttachment((String) json.getValue("attachment")); } if (json.getValue("companyid") instanceof Number) { obj.setCompanyid(((Number) json.getValue("companyid")).intValue()); } if (json.getValue("createtime") instanceof String) { obj.setCreatetime((String) json.getValue("createtime")); } if (json.getValue("deliverymode") instanceof Number) { obj.setDeliverymode(((Number) json.getValue("deliverymode")).intValue()); } if (json.getValue("drivername") instanceof String) { obj.setDrivername((String) json.getValue("drivername")); } if (json.getValue("endway") instanceof Number) { obj.setEndway(((Number) json.getValue("endway")).intValue()); } if (json.getValue("fhaddress") instanceof String) { obj.setFhaddress((String) json.getValue("fhaddress")); } if (json.getValue("fhlatitude") instanceof Number) { obj.setFhlatitude(((Number) json.getValue("fhlatitude")).doubleValue()); } if (json.getValue("fhlongitude") instanceof Number) { obj.setFhlongitude(((Number) json.getValue("fhlongitude")).doubleValue()); } if (json.getValue("fhname") instanceof String) { obj.setFhname((String) json.getValue("fhname")); } if (json.getValue("fhphone") instanceof String) { obj.setFhphone((String) json.getValue("fhphone")); } if (json.getValue("fhtime") instanceof String) { obj.setFhtime((String) json.getValue("fhtime")); } if (json.getValue("fhunit") instanceof String) { obj.setFhunit((String) json.getValue("fhunit")); } if (json.getValue("fhunitphone") instanceof String) { obj.setFhunitphone((String) json.getValue("fhunitphone")); } if (json.getValue("id") instanceof Number) { obj.setId(((Number) json.getValue("id")).intValue()); } if (json.getValue("licenseplate") instanceof String) { obj.setLicenseplate((String) json.getValue("licenseplate")); } if (json.getValue("memo") instanceof String) { obj.setMemo((String) json.getValue("memo")); } if (json.getValue("orderno") instanceof String) { obj.setOrderno((String) json.getValue("orderno")); } if (json.getValue("packagecount") instanceof Number) { obj.setPackagecount(((Number) json.getValue("packagecount")).doubleValue()); } if (json.getValue("packing") instanceof String) { obj.setPacking((String) json.getValue("packing")); } if (json.getValue("paperreceipt") instanceof Number) { obj.setPaperreceipt(((Number) json.getValue("paperreceipt")).intValue()); } if (json.getValue("paymentmode") instanceof Number) { obj.setPaymentmode(((Number) json.getValue("paymentmode")).intValue()); } if (json.getValue("productcode") instanceof String) { obj.setProductcode((String) json.getValue("productcode")); } if (json.getValue("productname") instanceof String) { obj.setProductname((String) json.getValue("productname")); } if (json.getValue("sdtime") instanceof String) { obj.setSdtime((String) json.getValue("sdtime")); } if (json.getValue("shaddress") instanceof String) { obj.setShaddress((String) json.getValue("shaddress")); } if (json.getValue("shlatitude") instanceof Number) { obj.setShlatitude(((Number) json.getValue("shlatitude")).doubleValue()); } if (json.getValue("shlongitude") instanceof Number) { obj.setShlongitude(((Number) json.getValue("shlongitude")).doubleValue()); } if (json.getValue("shname") instanceof String) { obj.setShname((String) json.getValue("shname")); } if (json.getValue("shphone") instanceof String) { obj.setShphone((String) json.getValue("shphone")); } if (json.getValue("shtime") instanceof String) { obj.setShtime((String) json.getValue("shtime")); } if (json.getValue("shunit") instanceof String) { obj.setShunit((String) json.getValue("shunit")); } if (json.getValue("shunitphone") instanceof String) { obj.setShunitphone((String) json.getValue("shunitphone")); } if (json.getValue("status") instanceof Number) { obj.setStatus(((Number) json.getValue("status")).intValue()); } if (json.getValue("totalfee") instanceof Number) { obj.setTotalfee(((Number) json.getValue("totalfee")).doubleValue()); } if (json.getValue("updatetime") instanceof String) { obj.setUpdatetime((String) json.getValue("updatetime")); } if (json.getValue("weight") instanceof Number) { obj.setWeight(((Number) json.getValue("weight")).doubleValue()); } }
From source file:com.funmix.entity.SiteConverter.java
License:Apache License
public static void fromJson(JsonObject json, Site obj) { if (json.getValue("address") instanceof String) { obj.setAddress((String) json.getValue("address")); }/* w w w .ja v a 2 s.com*/ if (json.getValue("contact") instanceof String) { obj.setContact((String) json.getValue("contact")); } if (json.getValue("contact_phone") instanceof String) { obj.setContact_phone((String) json.getValue("contact_phone")); } if (json.getValue("id") instanceof Number) { obj.setId(((Number) json.getValue("id")).intValue()); } if (json.getValue("latitude") instanceof Number) { obj.setLatitude(((Number) json.getValue("latitude")).doubleValue()); } if (json.getValue("longitude") instanceof Number) { obj.setLongitude(((Number) json.getValue("longitude")).doubleValue()); } if (json.getValue("memo") instanceof String) { obj.setMemo((String) json.getValue("memo")); } if (json.getValue("phone") instanceof String) { obj.setPhone((String) json.getValue("phone")); } if (json.getValue("sitename") instanceof String) { obj.setSitename((String) json.getValue("sitename")); } }
From source file:com.funmix.entity.TruckConverter.java
License:Apache License
public static void fromJson(JsonObject json, Truck obj) { if (json.getValue("id") instanceof Number) { obj.setId(((Number) json.getValue("id")).intValue()); }/*from w w w . j a va 2s . c om*/ if (json.getValue("lastupdate") instanceof String) { obj.setLastupdate((String) json.getValue("lastupdate")); } if (json.getValue("latitude") instanceof Number) { obj.setLatitude(((Number) json.getValue("latitude")).doubleValue()); } if (json.getValue("licenseplate") instanceof String) { obj.setLicenseplate((String) json.getValue("licenseplate")); } if (json.getValue("longitude") instanceof Number) { obj.setLongitude(((Number) json.getValue("longitude")).doubleValue()); } if (json.getValue("tonnage") instanceof Number) { obj.setTonnage(((Number) json.getValue("tonnage")).doubleValue()); } if (json.getValue("truck_type") instanceof String) { obj.setTruck_type((String) json.getValue("truck_type")); } if (json.getValue("volume_height") instanceof Number) { obj.setVolume_height(((Number) json.getValue("volume_height")).doubleValue()); } if (json.getValue("volume_length") instanceof Number) { obj.setVolume_length(((Number) json.getValue("volume_length")).doubleValue()); } if (json.getValue("volume_width") instanceof Number) { obj.setVolume_width(((Number) json.getValue("volume_width")).doubleValue()); } }
From source file:com.funmix.entity.UserConverter.java
License:Apache License
public static void fromJson(JsonObject json, User obj) { //if (json.getValue("access_status") instanceof Number) { obj.setAccess_status(((Number) json.getValue("access_status")).intValue()); //}// w w w . ja v a 2s.c om if (json.getValue("api_routers") instanceof String) { obj.setApi_routers((String) json.getValue("api_routers")); } //if (json.getValue("companyid") instanceof Number) { obj.setCompanyid(((Number) json.getValue("companyid")).intValue()); //} if (json.getValue("created_time") instanceof String) { obj.setCreated_time((String) json.getValue("created_time")); } if (json.getValue("default_web_routers") instanceof String) { obj.setDefault_web_routers((String) json.getValue("default_web_routers")); } if (json.getValue("email") instanceof String) { obj.setEmail((String) json.getValue("email")); } //if (json.getValue("id") instanceof Number) { obj.setId(((Number) json.getValue("id")).intValue()); //} if (json.getValue("password") instanceof String) { obj.setPassword((String) json.getValue("password")); } if (json.getValue("phone") instanceof String) { obj.setPhone((String) json.getValue("phone")); } //if (json.getValue("status") instanceof Number) { obj.setStatus(((Number) json.getValue("status")).intValue()); //} if (json.getValue("token") instanceof String) { obj.setToken((String) json.getValue("token")); } if (json.getValue("username") instanceof String) { obj.setUsername((String) json.getValue("username")); } if (json.getValue("web_routers") instanceof String) { obj.setWeb_routers((String) json.getValue("web_routers")); } }
From source file:com.funmix.service.DriverServiceImpl.java
@Override public Future<JsonObject> getAll(JsonObject params) { Future<JsonObject> result = Future.future(); StringBuffer sqlCount = new StringBuffer(SQL_QUERY_COUNT); StringBuffer sqlQuery = new StringBuffer(SQL_QUERY_ALL); StringBuffer order = new StringBuffer(); StringBuffer where = new StringBuffer(); JsonArray queryparams = new JsonArray(); JsonArray countparams = new JsonArray(); params.forEach(r -> {/*www. j a v a 2s . c om*/ String key = r.getKey(); if (key.equals("orderby")) { order.append(" order by ").append(r.getValue()); } else if (key.equals("page")) { } else if (key.equals("page_size")) { } else { if (where.length() == 0) where.append(" where "); else where.append(" and "); where.append(key).append(" like ? "); queryparams.add("%" + r.getValue() + "%"); countparams.add("%" + r.getValue() + "%"); } }); if (where.length() > 0) { sqlCount.append(where); sqlQuery.append(where); } JsonObject jrs = new JsonObject(); client.getConnection(connHandler(result, connection -> { log.info(sqlCount); if (countparams.size() == 0) connection.query(sqlCount.toString(), r -> { if (r.failed()) { result.fail(r.cause()); } else { int count = r.result().getRows().get(0).getInteger("count"); jrs.put("total", count); } }); else connection.queryWithParams(sqlCount.toString(), countparams, r -> { if (r.failed()) { result.fail(r.cause()); } else { int count = r.result().getRows().get(0).getInteger("count"); jrs.put("total", count); } }); if (order.length() > 0) { sqlQuery.append(order); queryparams.add(params.getString("orderby")); } if (params.getValue("page") == null) { params.put("page", "0"); params.put("page_size", "" + Integer.MAX_VALUE); } sqlQuery.append(" limit ?,? "); log.info(sqlQuery); int page = Integer.parseInt(params.getString("page")); int limit = Integer.parseInt(params.getString("page_size")); queryparams.add(Utils.calcPage(page, limit)).add(limit); connection.queryWithParams(sqlQuery.toString(), queryparams, r -> { if (r.failed()) { result.fail(r.cause()); } else { jrs.put("data", r.result().getRows().stream().map(Driver::new).collect(Collectors.toList())); jrs.put("per_page", limit); jrs.put("current_page", page); } result.complete(new JsonObject().put("status", 200).put("data", new JsonObject().put("list", jrs))); }); connection.close(); })); return result; }
From source file:com.funmix.service.LineServiceImpl.java
@Override public Future<JsonObject> getAll(JsonObject params) { Future<JsonObject> result = Future.future(); StringBuffer sqlCount = new StringBuffer(SQL_QUERY_COUNT); StringBuffer sqlQuery = new StringBuffer(SQL_QUERY_ALL); StringBuffer order = new StringBuffer(); StringBuffer where = new StringBuffer(); JsonArray queryparams = new JsonArray(); JsonArray countparams = new JsonArray(); params.forEach(r -> {/* ww w.j a v a 2 s . co m*/ String key = r.getKey(); if (key.equals("orderby")) { order.append(" order by ").append(r.getValue()); } else if (key.equals("page")) { } else if (key.equals("page_size")) { } else { if (where.length() == 0) where.append(" where "); else where.append(" and "); where.append(key).append(" like ? "); queryparams.add("%" + r.getValue() + "%"); countparams.add("%" + r.getValue() + "%"); } }); if (where.length() > 0) { sqlCount.append(where); sqlQuery.append(where); } JsonObject jrs = new JsonObject(); client.getConnection(connHandler(result, connection -> { log.info(sqlCount); if (countparams.size() == 0) connection.query(sqlCount.toString(), r -> { if (r.failed()) { result.fail(r.cause()); } else { int count = r.result().getRows().get(0).getInteger("count"); jrs.put("total", count); } }); else connection.queryWithParams(sqlCount.toString(), countparams, r -> { if (r.failed()) { result.fail(r.cause()); } else { int count = r.result().getRows().get(0).getInteger("count"); jrs.put("total", count); } }); if (order.length() > 0) { sqlQuery.append(order); queryparams.add(params.getString("orderby")); } if (params.getValue("page") == null) { params.put("page", "0"); params.put("page_size", "" + Integer.MAX_VALUE); } sqlQuery.append(" limit ?,? "); log.info(sqlQuery); int page = Integer.parseInt(params.getString("page")); int limit = Integer.parseInt(params.getString("page_size")); queryparams.add(Utils.calcPage(page, limit)).add(limit); connection.queryWithParams(sqlQuery.toString(), queryparams, r -> { if (r.failed()) { result.fail(r.cause()); } else { log.info(r.result().getRows().toString()); jrs.put("data", r.result().getRows().stream().map(Line::new).collect(Collectors.toList())); jrs.put("per_page", limit); jrs.put("current_page", page); } result.complete(new JsonObject().put("status", 200).put("data", new JsonObject().put("list", jrs))); }); connection.close(); })); return result; }
From source file:com.funmix.service.LineServiceImpl.java
@Override public Future<Optional<Line>> insert(JsonObject json) { log.info(json.toString());/*from ww w . j av a 2 s . co m*/ Future<Optional<Line>> result = Future.future(); JsonArray params = new JsonArray(); // licenseplate,drivername,startaddr,starttime,endtime,endaddr,linename,path params.add(json.getString("licenseplate")); params.add(json.getString("drivername")); params.add(json.getString("startaddr")); params.add(json.getString("starttime")); params.add(json.getString("endtime")); params.add(json.getString("endaddr")); params.add(json.getString("linename")); params.add(json.getJsonArray("path").toString()); StringBuffer updateOrder = new StringBuffer("update torder set status=2 where orderno in ("); JsonArray setparams = new JsonArray(); if (json.getValue("orderlist") != null) { JsonArray ja = json.getJsonArray("orderlist"); ja.forEach(r -> { updateOrder.append("?,"); setparams.add(r); }); updateOrder.deleteCharAt(updateOrder.length() - 1).append(")"); } log.info(setparams.toString()); log.info(params.toString()); client.getConnection(connHandler(result, connection -> { connection.updateWithParams(updateOrder.toString(), setparams, ru -> { if (ru.failed()) { result.fail(ru.cause()); log.info(ru.cause()); } else { connection.updateWithParams(SQL_INSERT, params, r -> { if (r.failed()) { result.fail(r.cause()); log.info(r.cause()); } else { UpdateResult urs = r.result(); params.clear(); params.add(urs.getKeys().getInteger(0)); log.info(urs.getKeys().getInteger(0)); connection.queryWithParams(SQL_QUERY, params, rs -> { if (rs.failed()) { result.fail(rs.cause()); log.info(rs.cause()); } else { List<JsonObject> list = rs.result().getRows(); if (list == null || list.isEmpty()) { result.complete(Optional.empty()); } else { result.complete(Optional.of(new Line(list.get(0)))); } } }); } connection.close(); }); } }); })); return result; }
From source file:com.funmix.service.TruckServiceImpl.java
@Override public Future<JsonObject> getAll(JsonObject params) { Future<JsonObject> result = Future.future(); StringBuffer sqlCount = new StringBuffer(SQL_QUERY_COUNT); StringBuffer sqlQuery = new StringBuffer(SQL_QUERY_ALL); StringBuffer order = new StringBuffer(); StringBuffer where = new StringBuffer(); JsonArray queryparams = new JsonArray(); JsonArray countparams = new JsonArray(); params.forEach(r -> {/*from ww w.ja va 2 s .com*/ String key = r.getKey(); if (key.equals("orderby")) { order.append(" order by ").append(r.getValue()); } else if (key.equals("page")) { } else if (key.equals("page_size")) { } else { if (where.length() == 0) where.append(" where "); else where.append(" and "); where.append(key).append(" like ? "); queryparams.add("%" + r.getValue() + "%"); countparams.add("%" + r.getValue() + "%"); } }); if (where.length() > 0) { sqlCount.append(where); sqlQuery.append(where); } JsonObject jrs = new JsonObject(); client.getConnection(connHandler(result, connection -> { log.info(sqlCount); if (countparams.size() == 0) connection.query(sqlCount.toString(), r -> { if (r.failed()) { result.fail(r.cause()); } else { int count = r.result().getRows().get(0).getInteger("count"); jrs.put("total", count); } }); else connection.queryWithParams(sqlCount.toString(), countparams, r -> { if (r.failed()) { result.fail(r.cause()); } else { int count = r.result().getRows().get(0).getInteger("count"); jrs.put("total", count); } }); if (order.length() > 0) { sqlQuery.append(order); queryparams.add(params.getString("orderby")); } if (params.getValue("page") == null) { params.put("page", "0"); params.put("page_size", "" + Integer.MAX_VALUE); } sqlQuery.append(" limit ?,? "); log.info(sqlQuery); int page = Integer.parseInt(params.getString("page")); int limit = Integer.parseInt(params.getString("page_size")); queryparams.add(Utils.calcPage(page, limit)).add(limit); connection.queryWithParams(sqlQuery.toString(), queryparams, r -> { if (r.failed()) { result.fail(r.cause()); } else { jrs.put("data", r.result().getRows().stream().map(Truck::new).collect(Collectors.toList())); jrs.put("per_page", limit); jrs.put("current_page", page); } result.complete(new JsonObject().put("status", 200).put("data", new JsonObject().put("list", jrs))); }); connection.close(); })); return result; }