提交 c24bd78d authored 作者: 000516's avatar 000516

乐事MT&TT,逆地理编码

...@@ -37,8 +37,7 @@ public class LsDisStoreDaoImpl { ...@@ -37,8 +37,7 @@ public class LsDisStoreDaoImpl {
// 秋林:1ZKO0CGs6nm9HuZWR6ucRiu4p9kM8f3i // 秋林:1ZKO0CGs6nm9HuZWR6ucRiu4p9kM8f3i
private void updateanhui(List<LsDisStore> lsDisStores,Long ldsId){ private void updateanhui(List<LsDisStore> lsDisStores,Long ldsId){
for (LsDisStore lsDisStore : lsDisStores) { for (LsDisStore lsDisStore : lsDisStores) {
String outlet = lsDisStore.getOutletName()+lsDisStore.getOutletAddress(); String s = HttpUtil.get("https://api.map.baidu.com/geocoding/v3/?address="+lsDisStore.getOutletAddress()+"&output=json&ak=OI4hMr7tEUoDBhSYxcrOGslnnBfZmD2b");
String s = HttpUtil.get("https://api.map.baidu.com/geocoding/v3/?address="+outlet+"&output=json&ak=OI4hMr7tEUoDBhSYxcrOGslnnBfZmD2b&city="+lsDisStore.getReCity());
JSONObject bd = JSONObject.parseObject(s); JSONObject bd = JSONObject.parseObject(s);
Integer status = bd.getInteger("status"); Integer status = bd.getInteger("status");
if (status.intValue() >= 300 && status.intValue() <= 399){ if (status.intValue() >= 300 && status.intValue() <= 399){
...@@ -48,15 +47,21 @@ public class LsDisStoreDaoImpl { ...@@ -48,15 +47,21 @@ public class LsDisStoreDaoImpl {
if (status.intValue() != 0){ if (status.intValue() != 0){
continue; continue;
} }
JSONObject jo = bd.getJSONObject("result"); JSONObject jo = bd.getJSONObject("result");
String analysLevel = jo.getString("level");
lsDisStore.setLat(analysLevel);
if (!analysLevel.equals("省") && !analysLevel.equals("城市")){
JSONObject location = jo.getJSONObject("location"); JSONObject location = jo.getJSONObject("location");
Float lng = location.getFloat("lng"); Float lng = location.getFloat("lng");
Float lat = location.getFloat("lat"); Float lat = location.getFloat("lat");
lsDisStore.setLng(lat+","+lng); lsDisStore.setLng(lat+","+lng);
} //
// String analysLevel = jo.getString("level");
// lsDisStore.setLat(analysLevel);
// if (!analysLevel.equals("省") && !analysLevel.equals("城市")){
// JSONObject location = jo.getJSONObject("location");
// Float lng = location.getFloat("lng");
// Float lat = location.getFloat("lat");
// lsDisStore.setLng(lat+","+lng);
// }
} }
lsDisStoreMapper.updateListO(lsDisStores); lsDisStoreMapper.updateListO(lsDisStores);
baiduAddressAnHui(ldsId); baiduAddressAnHui(ldsId);
...@@ -76,8 +81,7 @@ public class LsDisStoreDaoImpl { ...@@ -76,8 +81,7 @@ public class LsDisStoreDaoImpl {
// 黄总:8ptRbXOnQNX2TTqGVVYv5AUw3vJZ77gZ // 黄总:8ptRbXOnQNX2TTqGVVYv5AUw3vJZ77gZ
private void updateGuangzhou(List<LsDisStore> lsDisStores,Long ldsId){ private void updateGuangzhou(List<LsDisStore> lsDisStores,Long ldsId){
for (LsDisStore lsDisStore : lsDisStores) { for (LsDisStore lsDisStore : lsDisStores) {
String outlet = lsDisStore.getOutletName()+lsDisStore.getOutletAddress(); String s = HttpUtil.get("https://api.map.baidu.com/geocoding/v3/?address="+lsDisStore.getOutletAddress()+"&output=json&ak=sJFYkogPGt8kI3xkkSPwQQ9T61b4GVQV");
String s = HttpUtil.get("https://api.map.baidu.com/geocoding/v3/?address="+outlet+"&output=json&ak=sJFYkogPGt8kI3xkkSPwQQ9T61b4GVQV&city="+lsDisStore.getReCity());
JSONObject bd = JSONObject.parseObject(s); JSONObject bd = JSONObject.parseObject(s);
Integer status = bd.getInteger("status"); Integer status = bd.getInteger("status");
if (status.intValue() >= 300 && status.intValue() <= 399){ if (status.intValue() >= 300 && status.intValue() <= 399){
...@@ -88,14 +92,18 @@ public class LsDisStoreDaoImpl { ...@@ -88,14 +92,18 @@ public class LsDisStoreDaoImpl {
continue; continue;
} }
JSONObject jo = bd.getJSONObject("result"); JSONObject jo = bd.getJSONObject("result");
String analysLevel = jo.getString("level");
lsDisStore.setLat(analysLevel);
if (!analysLevel.equals("省") && !analysLevel.equals("城市")){
JSONObject location = jo.getJSONObject("location"); JSONObject location = jo.getJSONObject("location");
Float lng = location.getFloat("lng"); Float lng = location.getFloat("lng");
Float lat = location.getFloat("lat"); Float lat = location.getFloat("lat");
lsDisStore.setLng(lat+","+lng); lsDisStore.setLng(lat+","+lng);
} // String analysLevel = jo.getString("level");
// lsDisStore.setLat(analysLevel);
// if (!analysLevel.equals("省") && !analysLevel.equals("城市")){
// JSONObject location = jo.getJSONObject("location");
// Float lng = location.getFloat("lng");
// Float lat = location.getFloat("lat");
// lsDisStore.setLng(lat+","+lng);
// }
} }
lsDisStoreMapper.updateListT(lsDisStores); lsDisStoreMapper.updateListT(lsDisStores);
baiduAddressGuangzhou(ldsId); baiduAddressGuangzhou(ldsId);
...@@ -115,8 +123,7 @@ public class LsDisStoreDaoImpl { ...@@ -115,8 +123,7 @@ public class LsDisStoreDaoImpl {
// 本才:anjhOkUMuRyTb3DZO6dMGRUCY2l0vAql // 本才:anjhOkUMuRyTb3DZO6dMGRUCY2l0vAql
private void updateanhuisp(List<LsDisStore> lsDisStores,Long ldsId){ private void updateanhuisp(List<LsDisStore> lsDisStores,Long ldsId){
for (LsDisStore lsDisStore : lsDisStores) { for (LsDisStore lsDisStore : lsDisStores) {
String outlet = lsDisStore.getOutletName()+lsDisStore.getOutletAddress(); String s = HttpUtil.get("https://api.map.baidu.com/geocoding/v3/?address="+lsDisStore.getOutletAddress()+"&output=json&ak=anjhOkUMuRyTb3DZO6dMGRUCY2l0vAql");
String s = HttpUtil.get("https://api.map.baidu.com/geocoding/v3/?address="+outlet+"&output=json&ak=anjhOkUMuRyTb3DZO6dMGRUCY2l0vAql&city="+lsDisStore.getReCity());
JSONObject bd = JSONObject.parseObject(s); JSONObject bd = JSONObject.parseObject(s);
Integer status = bd.getInteger("status"); Integer status = bd.getInteger("status");
if (status.intValue() >= 300 && status.intValue() <= 399){ if (status.intValue() >= 300 && status.intValue() <= 399){
...@@ -127,14 +134,19 @@ public class LsDisStoreDaoImpl { ...@@ -127,14 +134,19 @@ public class LsDisStoreDaoImpl {
continue; continue;
} }
JSONObject jo = bd.getJSONObject("result"); JSONObject jo = bd.getJSONObject("result");
String analysLevel = jo.getString("level");
lsDisStore.setLat(analysLevel);
if (!analysLevel.equals("省") && !analysLevel.equals("城市")){
JSONObject location = jo.getJSONObject("location"); JSONObject location = jo.getJSONObject("location");
Float lng = location.getFloat("lng"); Float lng = location.getFloat("lng");
Float lat = location.getFloat("lat"); Float lat = location.getFloat("lat");
lsDisStore.setLng(lat+","+lng); lsDisStore.setLng(lat+","+lng);
}
// String analysLevel = jo.getString("level");
// lsDisStore.setLat(analysLevel);
// if (!analysLevel.equals("省") && !analysLevel.equals("城市")){
// JSONObject location = jo.getJSONObject("location");
// Float lng = location.getFloat("lng");
// Float lat = location.getFloat("lat");
// lsDisStore.setLng(lat+","+lng);
// }
} }
lsDisStoreMapper.updateListS(lsDisStores); lsDisStoreMapper.updateListS(lsDisStores);
baiduAddressAnHuisp(ldsId); baiduAddressAnHuisp(ldsId);
...@@ -167,8 +179,12 @@ public class LsDisStoreDaoImpl { ...@@ -167,8 +179,12 @@ public class LsDisStoreDaoImpl {
String formattedAddress = jo.getString("formatted_address"); String formattedAddress = jo.getString("formatted_address");
JSONObject ac = jo.getJSONObject("addressComponent"); JSONObject ac = jo.getJSONObject("addressComponent");
String province = ac.getString("province");
String city = ac.getString("city");
String district = ac.getString("district"); String district = ac.getString("district");
lsDisStore.setReProvince(province);
lsDisStore.setReAddress(formattedAddress); lsDisStore.setReAddress(formattedAddress);
lsDisStore.setReCity(city);
lsDisStore.setReArea(district); lsDisStore.setReArea(district);
} }
lsDisStoreMapper.updateListNO(lsDisStores); lsDisStoreMapper.updateListNO(lsDisStores);
...@@ -203,8 +219,12 @@ public class LsDisStoreDaoImpl { ...@@ -203,8 +219,12 @@ public class LsDisStoreDaoImpl {
String formattedAddress = jo.getString("formatted_address"); String formattedAddress = jo.getString("formatted_address");
JSONObject ac = jo.getJSONObject("addressComponent"); JSONObject ac = jo.getJSONObject("addressComponent");
String province = ac.getString("province");
String city = ac.getString("city");
String district = ac.getString("district"); String district = ac.getString("district");
lsDisStore.setReProvince(province);
lsDisStore.setReAddress(formattedAddress); lsDisStore.setReAddress(formattedAddress);
lsDisStore.setReCity(city);
lsDisStore.setReArea(district); lsDisStore.setReArea(district);
} }
lsDisStoreMapper.updateListNO(lsDisStores); lsDisStoreMapper.updateListNO(lsDisStores);
...@@ -237,8 +257,12 @@ public class LsDisStoreDaoImpl { ...@@ -237,8 +257,12 @@ public class LsDisStoreDaoImpl {
String formattedAddress = jo.getString("formatted_address"); String formattedAddress = jo.getString("formatted_address");
JSONObject ac = jo.getJSONObject("addressComponent"); JSONObject ac = jo.getJSONObject("addressComponent");
String province = ac.getString("province");
String city = ac.getString("city");
String district = ac.getString("district"); String district = ac.getString("district");
lsDisStore.setReProvince(province);
lsDisStore.setReAddress(formattedAddress); lsDisStore.setReAddress(formattedAddress);
lsDisStore.setReCity(city);
lsDisStore.setReArea(district); lsDisStore.setReArea(district);
} }
lsDisStoreMapper.updateListNO(lsDisStores); lsDisStoreMapper.updateListNO(lsDisStores);
...@@ -271,8 +295,12 @@ public class LsDisStoreDaoImpl { ...@@ -271,8 +295,12 @@ public class LsDisStoreDaoImpl {
String formattedAddress = jo.getString("formatted_address"); String formattedAddress = jo.getString("formatted_address");
JSONObject ac = jo.getJSONObject("addressComponent"); JSONObject ac = jo.getJSONObject("addressComponent");
String province = ac.getString("province");
String city = ac.getString("city");
String district = ac.getString("district"); String district = ac.getString("district");
lsDisStore.setReProvince(province);
lsDisStore.setReAddress(formattedAddress); lsDisStore.setReAddress(formattedAddress);
lsDisStore.setReCity(city);
lsDisStore.setReArea(district); lsDisStore.setReArea(district);
} }
lsDisStoreMapper.updateListNO(lsDisStores); lsDisStoreMapper.updateListNO(lsDisStores);
...@@ -305,8 +333,12 @@ public class LsDisStoreDaoImpl { ...@@ -305,8 +333,12 @@ public class LsDisStoreDaoImpl {
String formattedAddress = jo.getString("formatted_address"); String formattedAddress = jo.getString("formatted_address");
JSONObject ac = jo.getJSONObject("addressComponent"); JSONObject ac = jo.getJSONObject("addressComponent");
String province = ac.getString("province");
String city = ac.getString("city");
String district = ac.getString("district"); String district = ac.getString("district");
lsDisStore.setReProvince(province);
lsDisStore.setReAddress(formattedAddress); lsDisStore.setReAddress(formattedAddress);
lsDisStore.setReCity(city);
lsDisStore.setReArea(district); lsDisStore.setReArea(district);
} }
lsDisStoreMapper.updateListNO(lsDisStores); lsDisStoreMapper.updateListNO(lsDisStores);
...@@ -339,8 +371,12 @@ public class LsDisStoreDaoImpl { ...@@ -339,8 +371,12 @@ public class LsDisStoreDaoImpl {
String formattedAddress = jo.getString("formatted_address"); String formattedAddress = jo.getString("formatted_address");
JSONObject ac = jo.getJSONObject("addressComponent"); JSONObject ac = jo.getJSONObject("addressComponent");
String province = ac.getString("province");
String city = ac.getString("city");
String district = ac.getString("district"); String district = ac.getString("district");
lsDisStore.setReProvince(province);
lsDisStore.setReAddress(formattedAddress); lsDisStore.setReAddress(formattedAddress);
lsDisStore.setReCity(city);
lsDisStore.setReArea(district); lsDisStore.setReArea(district);
} }
lsDisStoreMapper.updateListNO(lsDisStores); lsDisStoreMapper.updateListNO(lsDisStores);
......
...@@ -25,13 +25,13 @@ public class TestTask { ...@@ -25,13 +25,13 @@ public class TestTask {
@XxlJob("ls_store_guangzhou") @XxlJob("ls_store_guangzhou")
public void lsStoreGuangzhou() { public void lsStoreGuangzhou() {
lsDisStoreDaoImpl.baiduAddressGuangzhou(500000L); lsDisStoreDaoImpl.baiduAddressGuangzhou(40000L);
} }
@XxlJob("ls_store_ahsp") @XxlJob("ls_store_ahsp")
public void lsStoreAnHuisp() { public void lsStoreAnHuisp() {
lsDisStoreDaoImpl.baiduAddressAnHuisp(1000000L); lsDisStoreDaoImpl.baiduAddressAnHuisp(80000L);
} }
/** /**
...@@ -43,26 +43,26 @@ public class TestTask { ...@@ -43,26 +43,26 @@ public class TestTask {
} }
@XxlJob("ls_store_n_xy") @XxlJob("ls_store_n_xy")
public void lsStoreNXY() { public void lsStoreNXY() {
lsDisStoreDaoImpl.lsStoreNXY(250000L); lsDisStoreDaoImpl.lsStoreNXY(20000L);
} }
@XxlJob("ls_store_n_gh") @XxlJob("ls_store_n_gh")
public void lsStoreNGH() { public void lsStoreNGH() {
lsDisStoreDaoImpl.lsStoreNGH(500000L); lsDisStoreDaoImpl.lsStoreNGH(40000L);
} }
@XxlJob("ls_store_n_hs") @XxlJob("ls_store_n_hs")
public void lsStoreNHS() { public void lsStoreNHS() {
lsDisStoreDaoImpl.lsStoreNHS(750000L); lsDisStoreDaoImpl.lsStoreNHS(60000L);
} }
@XxlJob("ls_store_n_dx") @XxlJob("ls_store_n_dx")
public void lsStoreNDX() { public void lsStoreNDX() {
lsDisStoreDaoImpl.lsStoreNDX(1000000L); lsDisStoreDaoImpl.lsStoreNDX(80000L);
} }
@XxlJob("ls_store_n_ql") // @XxlJob("ls_store_n_ql")
public void lsStoreNQL() { // public void lsStoreNQL() {
lsDisStoreDaoImpl.lsStoreNQL(1250000L); // lsDisStoreDaoImpl.lsStoreNQL(120000L);
} // }
} }
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<!-- 修改 limit 数量--> <!-- 修改 limit 数量-->
<select id="selectBaseO" resultMap="LsDisStoreBase"> <select id="selectBaseO" resultMap="LsDisStoreBase">
select lds_if,re_province,re_city,outlet_address,outlet_name select lds_if,re_province,re_city,outlet_address,outlet_name
from ls_dis_store where lds_if &gt; #{lastId} and lds_if &lt;= 500000 and re_area is null and lng is null limit 1000; from ls_dis_store where lds_if &gt; #{lastId} and lds_if &lt;= 40000 and lng is null limit 1000;
</select> </select>
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<select id="selectBaseT" resultMap="LsDisStoreBase"> <select id="selectBaseT" resultMap="LsDisStoreBase">
select lds_if,re_province,re_city,outlet_address,outlet_name select lds_if,re_province,re_city,outlet_address,outlet_name
from ls_dis_store where lds_if &gt; #{lastId} and lds_if &lt;= 1000000 and re_area is null and lng is null limit 1000; from ls_dis_store where lds_if &gt; #{lastId} and lds_if &lt;= 80000 and lng is null limit 1000;
</select> </select>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<select id="selectBaseS" resultMap="LsDisStoreBase"> <select id="selectBaseS" resultMap="LsDisStoreBase">
select lds_if,re_province,re_city,outlet_address,outlet_name select lds_if,re_province,re_city,outlet_address,outlet_name
from ls_dis_store where lds_if &gt; #{lastId} and lds_if &lt;= 1537130 and re_area is null and lng is null limit 1000; from ls_dis_store where lds_if &gt; #{lastId} and lds_if &lt;= 120000 and lng is null limit 1000;
</select> </select>
...@@ -74,37 +74,37 @@ ...@@ -74,37 +74,37 @@
<select id="selectBaseLO" resultMap="LsDisStoreBase"> <select id="selectBaseLO" resultMap="LsDisStoreBase">
select lds_if,lng select lds_if,lng
from ls_dis_store where lng is not null and re_area is null limit 1000; from ls_dis_store where lng is not null and re_city is null and lds_if &gt; #{lastId} and lds_if &lt;= 20000 limit 1000;
</select> </select>
<select id="selectBaseLT" resultMap="LsDisStoreBase"> <select id="selectBaseLT" resultMap="LsDisStoreBase">
select lds_if,lng select lds_if,lng
from ls_dis_store where lng is not null and re_area is null and lds_if &gt; #{lastId} and lds_if &lt;= 500000 limit 1000; from ls_dis_store where lng is not null and re_city is null and lds_if &gt; #{lastId} and lds_if &lt;= 40000 limit 1000;
</select> </select>
<select id="selectBaseLS" resultMap="LsDisStoreBase"> <select id="selectBaseLS" resultMap="LsDisStoreBase">
select lds_if,lng select lds_if,lng
from ls_dis_store where lng is not null and re_area is null and lds_if &gt; #{lastId} and lds_if &lt;= 750000 limit 1000; from ls_dis_store where lng is not null and re_city is null and lds_if &gt; #{lastId} and lds_if &lt;= 60000 limit 1000;
</select> </select>
<select id="selectBaseLF" resultMap="LsDisStoreBase"> <select id="selectBaseLF" resultMap="LsDisStoreBase">
select lds_if,lng select lds_if,lng
from ls_dis_store where lng is not null and re_area is null and lds_if &gt; #{lastId} and lds_if &lt;= 1000000 limit 1000; from ls_dis_store where lng is not null and re_city is null and lds_if &gt; #{lastId} and lds_if &lt;= 80000 limit 1000;
</select> </select>
<select id="selectBaseLV" resultMap="LsDisStoreBase"> <select id="selectBaseLV" resultMap="LsDisStoreBase">
select lds_if,lng select lds_if,lng
from ls_dis_store where lng is not null and re_area is null and lds_if &gt; #{lastId} and lds_if &lt;= 1250000 limit 1000; from ls_dis_store where lng is not null and re_city is null and lds_if &gt; #{lastId} and lds_if &lt;= 120000 limit 1000;
</select> </select>
<select id="selectBaseLX" resultMap="LsDisStoreBase"> <select id="selectBaseLX" resultMap="LsDisStoreBase">
select lds_if,lng select lds_if,lng
from ls_dis_store where lng is not null and re_area is null and lds_if &gt; #{lastId} and lds_if &lt;= 1537130 limit 1000; from ls_dis_store where lng is not null and re_city is null and lds_if &gt; #{lastId} and lds_if &lt;= 1537130 limit 1000;
</select> </select>
<update id="updateListNO" parameterType="java.util.List"> <update id="updateListNO" parameterType="java.util.List">
<foreach collection="lsDisStores" item="item" separator=";"> <foreach collection="lsDisStores" item="item" separator=";">
update ls_dis_store set re_address = #{item.reAddress},re_area = #{item.reArea} where lds_if = #{item.ldsIf} update ls_dis_store set re_address = #{item.reAddress},re_area = #{item.reArea},re_province = #{item.reProvince},re_city = #{item.reCity} where lds_if = #{item.ldsIf}
</foreach> </foreach>
</update> </update>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论