diff --git a/app/build.gradle b/app/build.gradle index b71e1a2..03bc2e5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,5 +37,6 @@ dependencies { implementation project(path: ':foudations:mogo-passport') implementation project(path: ':foudations:mogo-commons') // implementation 'com.mogo.cloud:passport:1.0.0' - + implementation rootProject.ext.dependencies.rxjava + implementation rootProject.ext.dependencies.rxandroid } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b7affc2..87e7c81 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,6 +20,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/mogo/cloud/network/ApiService.java b/app/src/main/java/com/mogo/cloud/network/ApiService.java new file mode 100644 index 0000000..03fa1ff --- /dev/null +++ b/app/src/main/java/com/mogo/cloud/network/ApiService.java @@ -0,0 +1,22 @@ +package com.mogo.cloud.network; + +import com.mogo.cloud.network.V2XRoadDataRes; + +import java.util.Map; + +import io.reactivex.Observable; +import retrofit2.http.GET; +import retrofit2.http.QueryMap; + +/** + * created by wujifei on 2021/1/21 13:02 + * describe: + */ +public interface ApiService { + + /** + * 基于目的地预判的道路事件和违章高发情况的停车推荐 + */ + @GET("/yycp-geo-fence-carService/car/road/getRoadDataOfVehiclesRecommend") + Observable queryRoadDataOfVehiclesRecommend(@QueryMap Map parameters); +} diff --git a/app/src/main/java/com/mogo/cloud/network/BaseData.java b/app/src/main/java/com/mogo/cloud/network/BaseData.java new file mode 100644 index 0000000..ef14fd4 --- /dev/null +++ b/app/src/main/java/com/mogo/cloud/network/BaseData.java @@ -0,0 +1,12 @@ +package com.mogo.cloud.network; + +import java.io.Serializable; + +/** + * Created by congtaowang on 2019/1/7. + */ +public class BaseData implements Serializable, Cloneable { + + public int code = -1; + public String msg; +} diff --git a/app/src/main/java/com/mogo/cloud/network/NetworkActivity.java b/app/src/main/java/com/mogo/cloud/network/NetworkActivity.java new file mode 100644 index 0000000..38de9b3 --- /dev/null +++ b/app/src/main/java/com/mogo/cloud/network/NetworkActivity.java @@ -0,0 +1,83 @@ +package com.mogo.cloud.network; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +import com.google.gson.Gson; +import com.mogo.cloud.R; +import com.mogo.utils.network.RetrofitFactory; + +import java.util.HashMap; +import java.util.Map; + +import io.reactivex.Observer; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + +/** + * created by wujifei on 2021/1/21 12:26 + * describe: + */ +public class NetworkActivity extends AppCompatActivity { + private Button btn; + private TextView tvResult; + + + private ApiService apiService; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_network); + btn = (Button) findViewById(R.id.btn); + tvResult = (TextView) findViewById(R.id.tv_result); + apiService = RetrofitFactory.getInstance("http://dzt-test.zhidaozhixing.com") + .create(ApiService.class); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + tvResult.setText("结果显示"); + queryRoadData("ZD802C1938L10797"); + } + }); + } + + public void queryRoadData(String sn) { + if (apiService != null) { + Map map = new HashMap<>(); + map.put("sn", sn); + apiService.queryRoadDataOfVehiclesRecommend(map) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(V2XRoadDataRes value) { + tvResult.setText(new Gson().toJson(value)); + System.out.println(new Gson().toJson(value)); + } + + @Override + public void onError(Throwable e) { + tvResult.setText(e.toString()); + System.out.println(e); + } + + @Override + public void onComplete() { + + } + }); + } + } +} diff --git a/app/src/main/java/com/mogo/cloud/network/V2XRoadDataRes.java b/app/src/main/java/com/mogo/cloud/network/V2XRoadDataRes.java new file mode 100644 index 0000000..1f9ea39 --- /dev/null +++ b/app/src/main/java/com/mogo/cloud/network/V2XRoadDataRes.java @@ -0,0 +1,535 @@ +package com.mogo.cloud.network; + + + +import java.util.List; + +/** + * created by wujifei on 2020/12/24 11:05 + * describe:于目的地预判的道路事件和违章高发情况的停车推荐 返回数据 + */ +public class V2XRoadDataRes extends BaseData { + + private String detailMsg; + private ResultDTO result; + + public String getDetailMsg() { + return detailMsg; + } + + public void setDetailMsg(String detailMsg) { + this.detailMsg = detailMsg; + } + + public ResultDTO getResult() { + return result; + } + + public void setResult(ResultDTO result) { + this.result = result; + } + + public static class ResultDTO { + private String formatAddress; + private List fromPoint; + private List topPoint; + private List poiData; + private List illegalParkingData; + + public String getFormatAddress() { + return formatAddress; + } + + public void setFormatAddress(String formatAddress) { + this.formatAddress = formatAddress; + } + + public List getFromPoint() { + return fromPoint; + } + + public void setFromPoint(List fromPoint) { + this.fromPoint = fromPoint; + } + + public List getTopPoint() { + return topPoint; + } + + public void setTopPoint(List topPoint) { + this.topPoint = topPoint; + } + + public List getPoiData() { + return poiData; + } + + public void setPoiData(List poiData) { + this.poiData = poiData; + } + + public List getIllegalParkingData() { + return illegalParkingData; + } + + public void setIllegalParkingData(List illegalParkingData) { + this.illegalParkingData = illegalParkingData; + } + + public static class PoiDataDTO { + /** + * generateTime : 1607061691000 + * type : 0 + * lat : 39.988346 + * lon : 116.410857 + * direction : 333 + * items : [{"url":"http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/sso-server-image/1603181678357.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1607393278%3B1607400478%26q-key-time%3D1607393278%3B1607400478%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D78c0f738f4dae37e67c235561c78120b86433a04"}] + * cityName : + * distance : 21447 + * nickName : 独狼 + * headImgUrl : https://yycp-static-1255510688.cos.ap-beijing.myqcloud.com/defaultUserHeadImg/VN000015.jpg + * sn : + * userId : 0 + * trafficInfoType : 0 + * infoId : 784423898000445440 + * poiType : 10015 + * uploadType : 2 + * likeNum : 3 + * systemLikeNum : 3 + * fabulous : false + */ + + + private long generateTime; + + private int type; + private double lat; + private double lon; + + private int direction; + private String cityName; + + private int distance; + private String nickName; + + private String headImgUrl; + + private String sn; + + private long userId; + + private String trafficInfoType; + + private String infoId; + + private String poiType; + + private String uploadType; + + private int likeNum; + + private int systemLikeNum; + + private boolean fabulous; + + private List items; + + public long getGenerateTime() { + return generateTime; + } + + public void setGenerateTime(long generateTime) { + this.generateTime = generateTime; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public int getDirection() { + return direction; + } + + public void setDirection(int direction) { + this.direction = direction; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public int getDistance() { + return distance; + } + + public void setDistance(int distance) { + this.distance = distance; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getHeadImgUrl() { + return headImgUrl; + } + + public void setHeadImgUrl(String headImgUrl) { + this.headImgUrl = headImgUrl; + } + + public String getSn() { + return sn; + } + + public void setSn(String sn) { + this.sn = sn; + } + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + public String getTrafficInfoType() { + return trafficInfoType; + } + + public void setTrafficInfoType(String trafficInfoType) { + this.trafficInfoType = trafficInfoType; + } + + public String getInfoId() { + return infoId; + } + + public void setInfoId(String infoId) { + this.infoId = infoId; + } + + public String getPoiType() { + return poiType; + } + + public void setPoiType(String poiType) { + this.poiType = poiType; + } + + public String getUploadType() { + return uploadType; + } + + public void setUploadType(String uploadType) { + this.uploadType = uploadType; + } + + public int getLikeNum() { + return likeNum; + } + + public void setLikeNum(int likeNum) { + this.likeNum = likeNum; + } + + public int getSystemLikeNum() { + return systemLikeNum; + } + + public void setSystemLikeNum(int systemLikeNum) { + this.systemLikeNum = systemLikeNum; + } + + public boolean isFabulous() { + return fabulous; + } + + public void setFabulous(boolean fabulous) { + this.fabulous = fabulous; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + + public static class ItemsDTO { + /** + * url : http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/sso-server-image/1603181678357.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1607393278%3B1607400478%26q-key-time%3D1607393278%3B1607400478%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D78c0f738f4dae37e67c235561c78120b86433a04 + */ + + + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + } + } + + + public static class IllegalParkingDataDTO { + /** + * generateTime : 1594047156488 + * type : 3 + * lat : 40.028599 + * lon : 116.412712 + * direction : 0 + * addr : 红军营南路红军营南路万科星园北口至红军营南路北苑路口段 + * items : [] + * cityName : + * distance : 6728 + * nickName : + * headImgUrl : + * sn : + * userId : 0 + * trafficInfoType : 0 + * infoId : 686267 + * poiType : 10016 + * uploadType : 3 + * likeNum : 0 + * systemLikeNum : 0 + * fabulous : false + */ + + + private long generateTime; + + private int type; + + private double lat; + + private double lon; + + private int direction; + + private String addr; + + private String cityName; + + private int distance; + + private String nickName; + + private String headImgUrl; + + private String sn; + + private long userId; + + private String trafficInfoType; + + private String infoId; + + private String poiType; + + private String uploadType; + + private int likeNum; + + private int systemLikeNum; + + private boolean fabulous; + + private List items; + + public long getGenerateTime() { + return generateTime; + } + + public void setGenerateTime(long generateTime) { + this.generateTime = generateTime; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public int getDirection() { + return direction; + } + + public void setDirection(int direction) { + this.direction = direction; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public int getDistance() { + return distance; + } + + public void setDistance(int distance) { + this.distance = distance; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getHeadImgUrl() { + return headImgUrl; + } + + public void setHeadImgUrl(String headImgUrl) { + this.headImgUrl = headImgUrl; + } + + public String getSn() { + return sn; + } + + public void setSn(String sn) { + this.sn = sn; + } + + public long getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + + public String getTrafficInfoType() { + return trafficInfoType; + } + + public void setTrafficInfoType(String trafficInfoType) { + this.trafficInfoType = trafficInfoType; + } + + public String getInfoId() { + return infoId; + } + + public void setInfoId(String infoId) { + this.infoId = infoId; + } + + public String getPoiType() { + return poiType; + } + + public void setPoiType(String poiType) { + this.poiType = poiType; + } + + public String getUploadType() { + return uploadType; + } + + public void setUploadType(String uploadType) { + this.uploadType = uploadType; + } + + public int getLikeNum() { + return likeNum; + } + + public void setLikeNum(int likeNum) { + this.likeNum = likeNum; + } + + public int getSystemLikeNum() { + return systemLikeNum; + } + + public void setSystemLikeNum(int systemLikeNum) { + this.systemLikeNum = systemLikeNum; + } + + public boolean isFabulous() { + return fabulous; + } + + public void setFabulous(boolean fabulous) { + this.fabulous = fabulous; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + } + } +} diff --git a/app/src/main/res/layout/activity_network.xml b/app/src/main/res/layout/activity_network.xml new file mode 100644 index 0000000..f9d03b9 --- /dev/null +++ b/app/src/main/res/layout/activity_network.xml @@ -0,0 +1,19 @@ + + + +