//生成需求编号 public static String getRequireNo(String ids){ StringBuffer stringB = new StringBuffer(); Calendar c = Calendar.getInstance(); String year = String.valueOf(c.get(Calendar.YEAR));//获取年 year = year==null?"":year.substring(year.length()-2, year.length()); String month = String.valueOf(c.get(Calendar.MONTH)+1); // 获取月份 String day = String.valueOf(c.get(Calendar.DAY_OF_MONTH)); //获取日期 if(month.length() == 1){ month = "0" + month; } if(day.length() == 1){ day = "0" + day; } ids = getRequireId(ids); stringB.append("8").append(year).append(month).append(day).append(ids); return stringB.toString();
}
//////
//生成需求编号末尾的序号 public static String getSellerId(String ids){ if(ids==null){ return null; } StringBuffer number = new StringBuffer(); if(ids.length()==1){ number.append("K800000").append(ids); }else if(ids.length()==2){ number.append("K80000").append(ids); }else if(ids.length()==3){ number.append("K8000").append(ids); }else if(ids.length()==4){ number.append("K800").append(ids); }else if(ids.length()==5){ number.append("K80").append(ids); }else if(ids.length()==6){ number.append("K8").append(ids); }else if(ids.length()>=7){ number.append(ids); } return number.toString(); }
/**
* 获取系统附近地理位置
* @param lat 纬度
* @param lon 经度
*/
public static Map
JSONArray jsonArray=BaiDuUtil.getCity(String.valueOf(lat), String.valueOf(lon));
Iterator
public static JSONArray getCity(String lat, String lng) { JSONArray obj = getLocationInfo(lng, lat).getJSONArray("pois"); return obj; } public static JSONObject getLocationInfo(String lat, String lng) { String url = "http://restapi.amap.com/v3/place/around?location=" + lng + "," + lat + "&output=json&radius=500&offset=15&key=" + "f69af2fa030b5bcadcfca02caa536500"; JSONObject obj; obj = JSONObject.parseObject(HttpUtilnew.getRequest(url)); return obj; }
/** * 获取附近区域 * @param lat 纬度 * @param lng 经度 */ public static MapgetArea(String lat, String lng){ Map map = new HashMap (); JSONObject obj = getLocationInfo(lng, lat).getJSONObject("suggestion").getJSONObject("addressComponent"); map.put("province", obj.get("province")); map.put("city", obj.get("city")); map.put("district", obj.get("district")); return map; }
public static void main(String[] args) { Map> maps=getLocationMap(113.862808,22.581255); // while (it.hasNext()) { // JSONObject ob = (JSONObject) it.next(); // maps.put("point", ob.get("point")); System.out.println(maps); // } // System.out.println(BaiDuUtil.getArea("22.581255000426088", "113.86280799999997")); }
打印
{1={distance=12, province=广东省, pointx=113.862911, city=深圳市, pointy=22.581317, poiType=生活服务;美容美发店;美容美发店, district=宝安区, name=美度护肤造型连锁, id=B0FFLGXNEL, addr=}, 2={distance=16, province=广东省, pointx=113.862964, city=深圳市, pointy=22.581254, poiType=餐饮服务;中餐厅;广东菜(粤菜), district=宝安区, name=益香记花椒鸭, id=B0FFKVBJOL, addr=西乡街道盐田社区高树围西二巷17号101}, 3={distance=18, province=广东省, pointx=113.862988, city=深圳市, pointy=22.581247, poiType=餐饮服务;中餐厅;中餐厅, district=宝安区, name=缘爱鑫麻辣香锅, id=B0FFIMWJN1, addr=西乡街道高树围西三巷8-1}, 4={distance=18, province=广东省, pointx=113.862987, city=深圳市, pointy=22.581230, poiType=餐饮服务;中餐厅;中餐厅, district=宝安区, name=川香源麻辣香锅(西乡店), id=B0FFK57V1R, addr=金海路与高树围一巷交叉口南50米}, 5={distance=19, province=广东省, pointx=113.862828, city=深圳市, pointy=22.581425, poiType=生活服务;摄影冲印店;摄影冲印, district=宝安区, name=百年好合婚纱摄影机构(深圳直营店), id=B0FFF4DHT5, addr=金海路与高树围一巷交叉口西南50米}, 6={distance=21, province=广东省, pointx=113.863017, city=深圳市, pointy=22.581280, poiType=生活服务;美容美发店;美容美发店, district=宝安区, name=艺都三兄弟美发店, id=B0FFIZG0HC, addr=盐田社区高树围西二巷18号101}, 7={distance=22, province=广东省, pointx=113.863029, city=深圳市, pointy=22.581255, poiType=餐饮服务;快餐厅;快餐厅, district=宝安区, name=咸骨粥爽滑饺子王(西乡店), id=B0FFIIQHKB, addr=西乡街道共乐社区高树围西一巷21号103号}, 8={distance=23, province=广东省, pointx=113.863034, city=深圳市, pointy=22.581250, poiType=餐饮服务;中餐厅;中餐厅, district=宝安区, name=川香源麻辣香锅冒菜(西乡店), id=B0FFG6DHQD, addr=金海路高树围西二巷18号}, 9={distance=30, province=广东省, pointx=113.863072, city=深圳市, pointy=22.581375, poiType=生活服务;共享设备;充电宝, district=宝安区, name=小电(韩派专业美发), id=B0FFLGF9WW, addr=高树围村西一巷22号}, 10={distance=30, province=广东省, pointx=113.863072, city=深圳市, pointy=22.581375, poiType=生活服务;美容美发店;美容美发店, district=宝安区, name=韩派专业美发, id=B02F38RGWN, addr=高树围村西一巷22号}, 11={distance=31, province=广东省, pointx=113.863112, city=深圳市, pointy=22.581195, poiType=生活服务;美容美发店;美容美发店, district=宝安区, name=Mary Kay女子形象工作室, id=B0FFG7MYF1, addr=金海路金港华庭沃尔玛楼上}, 12={distance=32, province=广东省, pointx=113.862791, city=深圳市, pointy=22.580968, poiType=生活服务;洗浴推拿场所;洗浴推拿场所, district=宝安区, name=雅丰苑休闲会所(装修中), id=B02F38PGPS, addr=金海路3-2号雅丰苑商务酒店4层}, 13={distance=32, province=广东省, pointx=113.863118, city=深圳市, pointy=22.581323, poiType=餐饮服务;快餐厅;快餐厅, district=宝安区, name=龙记云浮石磨肠粉, id=B0FFK65TSH, addr=宝安大道4107-4109号}, 14={distance=32, province=广东省, pointx=113.862697, city=深圳市, pointy=22.580977, poiType=生活服务;旅行社;旅行社, district=宝安区, name=广东中旅(宝安碧海营业部), id=B0FFF5VZD6, addr=金海路3-2号雅丰苑商务酒店大堂}, 15={distance=33, province=广东省, pointx=113.862669, city=深圳市, pointy=22.580983, poiType=生活服务;共享设备;充电宝, district=宝安区, name=小电(西岸城酒楼), id=B0FFLGEZZ8, addr=金海路3-1号}}