|
|
@@ -4,10 +4,10 @@ import cn.reghao.jutil.jdk.serializer.JsonConverter;
|
|
|
import cn.reghao.jutil.jdk.text.TextFile;
|
|
|
import cn.reghao.oss.sdk.OssConsoleClient;
|
|
|
import cn.reghao.oss.sdk.model.OssConsoleConfig;
|
|
|
-import cn.reghao.oss.sdk.model.dto.ObjectInfo;
|
|
|
import cn.reghao.tnb.content.app.ContentApplication;
|
|
|
import cn.reghao.tnb.content.app.geo.db.mapper.*;
|
|
|
import cn.reghao.tnb.content.app.geo.model.po.*;
|
|
|
+import cn.reghao.tnb.content.app.geo.model.vo.GeoArea;
|
|
|
import cn.reghao.tnb.content.app.geo.model.vo.MapMarker;
|
|
|
import cn.reghao.tnb.content.app.geo.model.vo.MapPoint;
|
|
|
import com.google.gson.JsonObject;
|
|
|
@@ -17,10 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -32,42 +29,6 @@ import java.util.Map;
|
|
|
public class GeoTest {
|
|
|
@Autowired
|
|
|
MapService mapService;
|
|
|
- @Autowired
|
|
|
- GeoPointMapper geoPointMapper;
|
|
|
- @Test
|
|
|
- public void geoPointTest() {
|
|
|
- String lngN = "123.266667";
|
|
|
- String latN = "53.55";
|
|
|
-
|
|
|
- String lngS = "112.283333";
|
|
|
- String latS = "3.966667";
|
|
|
-
|
|
|
- String lngE = "134.7738";
|
|
|
- String latE = "47.7738";
|
|
|
-
|
|
|
- String lngW = "73.5";
|
|
|
- String latW = "39.38";
|
|
|
-
|
|
|
- MapPoint mapPointN = new MapPoint(lngN, latN);
|
|
|
- MapPoint mapPointS = new MapPoint(lngS, latS);
|
|
|
- MapPoint mapPointE = new MapPoint(lngE, latE);
|
|
|
- MapPoint mapPointW = new MapPoint(lngW, latW);
|
|
|
-
|
|
|
- /*List<GeoPoint> list = new ArrayList<>();
|
|
|
- list.add(new GeoPoint(mapPointN, "最北"));
|
|
|
- list.add(new GeoPoint(mapPointS, "最南"));
|
|
|
- list.add(new GeoPoint(mapPointE, "最东"));
|
|
|
- list.add(new GeoPoint(mapPointW, "最西"));
|
|
|
- geoPointMapper.saveAll(list);*/
|
|
|
-
|
|
|
- double lng = 104.061745;
|
|
|
- double lat = 30.658669;
|
|
|
- MapPoint mapPoint = new MapPoint(lng, lat);
|
|
|
- GeoChina geoChina = geoChinaMapper.findByPoint(mapPoint);
|
|
|
- if (geoChina != null) {
|
|
|
- System.out.printf("%s -> %s\n", geoChina.getId(), geoChina.getExtPath());
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
@Autowired
|
|
|
GeoChinaMapper geoChinaMapper;
|
|
|
@@ -160,10 +121,65 @@ public class GeoTest {
|
|
|
return sb.toString().trim();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ OssConsoleClient getOssConsoleClient() {
|
|
|
+ String consoleUrl = "http://bnt.reghao.cn";
|
|
|
+ String accessKeyId = "ESCKn3Cd";
|
|
|
+ String accessKeySecret = "OL9SIOLoOqUjhMiQMv";
|
|
|
+ int videoChannelId = 101;
|
|
|
+ OssConsoleConfig ossConsoleConfig = new OssConsoleConfig(consoleUrl, accessKeyId, accessKeySecret);
|
|
|
+ try {
|
|
|
+ OssConsoleClient ossConsoleClient = new OssConsoleClient(ossConsoleConfig);
|
|
|
+ return ossConsoleClient;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CameraPhotoMapper cameraPhotoMapper;
|
|
|
+ @Test
|
|
|
+ void photoMapTest() {
|
|
|
+ //OssConsoleClient ossConsoleClient = getOssConsoleClient();
|
|
|
+ List<CameraPhoto> list = cameraPhotoMapper.findAll();
|
|
|
+ for (CameraPhoto cameraPhoto : list) {
|
|
|
+ /*String objectId = cameraPhoto.getObjectId();
|
|
|
+ int channelId = cameraPhoto.getChannelId();
|
|
|
+ try {
|
|
|
+ ObjectInfo objectInfo = ossConsoleClient.getObjectInfo(channelId, objectId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("objectId {} not exist", objectId);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ BusStationMapper busStationMapper;
|
|
|
+ @Test
|
|
|
+ void geoBusTest() {
|
|
|
+ List<BusStation> list = busStationMapper.findAll();
|
|
|
+ for (BusStation busStation : list) {
|
|
|
+ String id = busStation.getId()+"";
|
|
|
+ String stationName = busStation.getStationName();
|
|
|
+ String latStr = String.valueOf(busStation.getLat());
|
|
|
+ String latStr1 = String.format("%s.%s", latStr.substring(0, 2), latStr.substring(2));
|
|
|
+ double lat = Double.parseDouble(latStr1);
|
|
|
+
|
|
|
+ String lngStr = String.valueOf(busStation.getLng());
|
|
|
+ String lngStr1 = String.format("%s.%s", lngStr.substring(0, 3), lngStr.substring(3));
|
|
|
+ double lng = Double.parseDouble(lngStr1);
|
|
|
+ MapPoint mapPoint = new MapPoint(lng, lat);
|
|
|
+
|
|
|
+ MapMarker mapMarker = new MapMarker(id, stationName, mapPoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
MallReplyMapper mallReplyMapper;
|
|
|
@Test
|
|
|
- public void test() {
|
|
|
+ public void updateCupTest() {
|
|
|
List<MallReply> list = mallReplyMapper.findAll();
|
|
|
list.forEach(mallReply -> {
|
|
|
String extra = mallReply.getExtra();
|
|
|
@@ -238,59 +254,21 @@ public class GeoTest {
|
|
|
return extra1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- OssConsoleClient getOssConsoleClient() {
|
|
|
- String consoleUrl = "http://bnt.reghao.cn";
|
|
|
- String accessKeyId = "ESCKn3Cd";
|
|
|
- String accessKeySecret = "OL9SIOLoOqUjhMiQMv";
|
|
|
- int videoChannelId = 101;
|
|
|
- OssConsoleConfig ossConsoleConfig = new OssConsoleConfig(consoleUrl, accessKeyId, accessKeySecret);
|
|
|
- try {
|
|
|
- OssConsoleClient ossConsoleClient = new OssConsoleClient(ossConsoleConfig);
|
|
|
- return ossConsoleClient;
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- CameraPhotoMapper cameraPhotoMapper;
|
|
|
@Test
|
|
|
- void photoMapTest() {
|
|
|
- OssConsoleClient ossConsoleClient = getOssConsoleClient();
|
|
|
-
|
|
|
+ public void updateAreaCodeTest() {
|
|
|
List<CameraPhoto> list = cameraPhotoMapper.findAll();
|
|
|
for (CameraPhoto cameraPhoto : list) {
|
|
|
- String objectId = cameraPhoto.getObjectId();
|
|
|
- int channelId = cameraPhoto.getChannelId();
|
|
|
- try {
|
|
|
- ObjectInfo objectInfo = ossConsoleClient.getObjectInfo(channelId, objectId);
|
|
|
- } catch (Exception e) {
|
|
|
- log.info("objectId {} not exist", objectId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- BusStationMapper busStationMapper;
|
|
|
- @Test
|
|
|
- void geoBusTest() {
|
|
|
- List<BusStation> list = busStationMapper.findAll();
|
|
|
- for (BusStation busStation : list) {
|
|
|
- String id = busStation.getId()+"";
|
|
|
- String stationName = busStation.getStationName();
|
|
|
- String latStr = String.valueOf(busStation.getLat());
|
|
|
- String latStr1 = String.format("%s.%s", latStr.substring(0, 2), latStr.substring(2));
|
|
|
- double lat = Double.parseDouble(latStr1);
|
|
|
-
|
|
|
- String lngStr = String.valueOf(busStation.getLng());
|
|
|
- String lngStr1 = String.format("%s.%s", lngStr.substring(0, 3), lngStr.substring(3));
|
|
|
- double lng = Double.parseDouble(lngStr1);
|
|
|
+ double lng = cameraPhoto.getLongitude().doubleValue();
|
|
|
+ double lat = cameraPhoto.getLatitude().doubleValue();
|
|
|
MapPoint mapPoint = new MapPoint(lng, lat);
|
|
|
-
|
|
|
- MapMarker mapMarker = new MapMarker(id, stationName, mapPoint);
|
|
|
+ GeoArea geoArea = geoChinaMapper.findByPoint(mapPoint);
|
|
|
+ if (geoArea != null) {
|
|
|
+ int areaCode = geoArea.getId();
|
|
|
+ String extPath = geoArea.getExtPath();
|
|
|
+ String objectId = cameraPhoto.getObjectId();
|
|
|
+ cameraPhotoMapper.updateSetAreaCode(objectId, areaCode);
|
|
|
+ log.info("update {} {} -> {}", objectId, areaCode, extPath);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|