定位服务
This commit is contained in:
parent
7d29c5ec89
commit
c5f16d7d17
@ -13,6 +13,7 @@ import com.dahe.mylibrary.net.CommonResponseBean;
|
|||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.PUT;
|
import retrofit2.http.PUT;
|
||||||
import retrofit2.http.Query;
|
import retrofit2.http.Query;
|
||||||
@ -118,5 +119,9 @@ public interface Api {
|
|||||||
|
|
||||||
@POST(BASE_URL+"/openapi/shipments/getPODImageNames")
|
@POST(BASE_URL+"/openapi/shipments/getPODImageNames")
|
||||||
Observable<CommonResponseBean> getPODImageNames(@Body ShipmentStatusBean bean);
|
Observable<CommonResponseBean> getPODImageNames(@Body ShipmentStatusBean bean);
|
||||||
|
|
||||||
|
|
||||||
|
@GET(BASE_URL+"/openapi/drivers")
|
||||||
|
Observable<CommonResponseBean> searchDriver(@Query("identityNo") String identityNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,14 +3,18 @@ package com.arpa.hndahesudintocctmsdriver.util;
|
|||||||
import static com.dahe.mylibrary.utils.BaseSPUtils.NEW_LJ_TOKEN;
|
import static com.dahe.mylibrary.utils.BaseSPUtils.NEW_LJ_TOKEN;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.arpa.hndahesudintocctmsdriver.bean.GDImage;
|
import com.arpa.hndahesudintocctmsdriver.bean.GDImage;
|
||||||
import com.arpa.hndahesudintocctmsdriver.bean.GDLocation;
|
import com.arpa.hndahesudintocctmsdriver.bean.GDLocation;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.bean.IsAuthCardBean;
|
||||||
import com.arpa.hndahesudintocctmsdriver.constant.NewLJConstant;
|
import com.arpa.hndahesudintocctmsdriver.constant.NewLJConstant;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.request.AuthRequest;
|
||||||
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.InvoiceBean;
|
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.InvoiceBean;
|
||||||
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.LjTokenBean;
|
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.LjTokenBean;
|
||||||
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.PickupBean;
|
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.PickupBean;
|
||||||
@ -19,11 +23,18 @@ import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.UpimgBean;
|
|||||||
import com.arpa.hndahesudintocctmsdriver.request.net.BaseObserver;
|
import com.arpa.hndahesudintocctmsdriver.request.net.BaseObserver;
|
||||||
import com.arpa.hndahesudintocctmsdriver.request.net.DataManager;
|
import com.arpa.hndahesudintocctmsdriver.request.net.DataManager;
|
||||||
import com.arpa.hndahesudintocctmsdriver.request.net.RxHttpCallBack;
|
import com.arpa.hndahesudintocctmsdriver.request.net.RxHttpCallBack;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.ui.auth.CertificatesActivity;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.util.cache.CacheGroup;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.util.http.RequestUtil;
|
||||||
|
import com.arpa.hndahesudintocctmsdriver.util.http.RequsetCodeConstants;
|
||||||
|
import com.dahe.mylibrary.bean.DriverBean;
|
||||||
import com.dahe.mylibrary.callback.OnGDDownloadResultListener;
|
import com.dahe.mylibrary.callback.OnGDDownloadResultListener;
|
||||||
import com.dahe.mylibrary.callback.OnGDResultListener;
|
import com.dahe.mylibrary.callback.OnGDResultListener;
|
||||||
import com.dahe.mylibrary.net.CommonResponseBean;
|
import com.dahe.mylibrary.net.CommonResponseBean;
|
||||||
import com.dahe.mylibrary.utils.ToastUtils;
|
import com.dahe.mylibrary.utils.ToastUtils;
|
||||||
import com.express.mdp.Api;
|
import com.express.mdp.Api;
|
||||||
|
import com.express.mdp.Callback;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
@ -66,6 +77,25 @@ public class NewLJUtils {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getToken(Context ctx,OnGDResultListener listener) {
|
||||||
|
LjTokenBean ljTokenBean = new LjTokenBean();
|
||||||
|
ljTokenBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
||||||
|
ljTokenBean.setEnterpriseIdentity(NewLJConstant.ENTER_PRISE_IDENTITY);
|
||||||
|
ljTokenBean.setEnterpriseKey(NewLJConstant.ENTER_PRISE_KEY);
|
||||||
|
|
||||||
|
DataManager.getInstance().getToken(ljTokenBean)
|
||||||
|
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(CommonResponseBean t) {
|
||||||
|
super.onSuccess(t);
|
||||||
|
SPUtils.put(ctx, NEW_LJ_TOKEN, t.getToken());
|
||||||
|
if (listener!=null)
|
||||||
|
listener.onSuccess();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运单提货
|
* 运单提货
|
||||||
@ -444,7 +474,7 @@ public class NewLJUtils {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getPODImageNames(Context ctx, String shipmentCode){
|
public void getPODImageNames(Context ctx, String shipmentCode) {
|
||||||
ShipmentStatusBean shipmentStatusBean = new ShipmentStatusBean();
|
ShipmentStatusBean shipmentStatusBean = new ShipmentStatusBean();
|
||||||
shipmentStatusBean.setShipmentCode(shipmentCode);
|
shipmentStatusBean.setShipmentCode(shipmentCode);
|
||||||
shipmentStatusBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
shipmentStatusBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
||||||
@ -468,24 +498,92 @@ public class NewLJUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启位置上传
|
* 开启位置上传
|
||||||
|
*
|
||||||
* @param act
|
* @param act
|
||||||
*/
|
*/
|
||||||
public void startLocationService(AppCompatActivity act){
|
public void startLocationService(AppCompatActivity act) {
|
||||||
try {
|
//查询身份证信息
|
||||||
Api.setBaseUrl("https://kehui56.cn/api","https://api.kehui56.cn/api");
|
new AuthRequest().getCard(act, new Handler(msg -> {
|
||||||
Api.startLocationService(act, NewLJConstant.ENTER_PRISE_CODE, s -> {
|
switch (msg.what) {
|
||||||
Log.e("位置上报", s);
|
case RequsetCodeConstants.ERROR:
|
||||||
});
|
Toast.makeText(act, RequsetCodeConstants.FEEDBACK_TEXT, Toast.LENGTH_SHORT).show();
|
||||||
} catch (Exception e) {
|
break;
|
||||||
throw new RuntimeException(e);
|
case RequsetCodeConstants.UNKONWN:
|
||||||
}
|
Toast.makeText(act, RequsetCodeConstants.UNKONWN_TEXT, Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
case RequsetCodeConstants.SERVER_ERROR:
|
||||||
|
Toast.makeText(act, RequsetCodeConstants.SERVER_ERROR_TEXT, Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
case RequsetCodeConstants.GATEWAY_ERROR:
|
||||||
|
Toast.makeText(act, RequsetCodeConstants.GATEWAY_ERROR_TEXT, Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
case RequsetCodeConstants.SUCCESS:
|
||||||
|
IsAuthCardBean iacb = new Gson().fromJson(CacheGroup.cacheList.get(CertificatesActivity.ISAUTH), IsAuthCardBean.class);
|
||||||
|
if (iacb != null || iacb.getData() != null || !TextUtils.isEmpty(iacb.getData().getIdcard())) {
|
||||||
|
//根据身份证号查询路交司机信息
|
||||||
|
searchDriver(act,iacb.getData().getIdcard(), new OnGDDownloadResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String var1) {
|
||||||
|
try {
|
||||||
|
//开启定位服务
|
||||||
|
Api.setBaseUrl("https://kehui56.cn/api", "https://api.kehui56.cn/api");
|
||||||
|
String result = Api.startLocationService(act, var1, s -> {
|
||||||
|
Log.e("位置上报", s);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(String var1, String var2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Toast.makeText(act, "缺少身份证信息", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭定位服务
|
* 关闭定位服务
|
||||||
*/
|
*/
|
||||||
public void stopLocationService(){
|
public void stopLocationService() {
|
||||||
Api.stopLocationService();
|
Api.stopLocationService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询司机
|
||||||
|
*/
|
||||||
|
public void searchDriver(Context ctx,String idCard, OnGDDownloadResultListener listener) {
|
||||||
|
DataManager.getInstance().searchDriver(idCard)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(CommonResponseBean<CommonResponseBean> t) {
|
||||||
|
super.onSuccess(t);
|
||||||
|
DriverBean driver = t.getDriver();
|
||||||
|
if (driver != null && !TextUtils.isEmpty(driver.getDriverCode())) {
|
||||||
|
if (listener != null)
|
||||||
|
listener.onSuccess(driver.getDriverCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
||||||
|
super.onCodeError(mContext, t);
|
||||||
|
if (listener!=null)
|
||||||
|
listener.onFailure(t.getCode(),t.getMessage());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.dahe.mylibrary.bean;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DriverBean
|
||||||
|
* @Author john
|
||||||
|
* @Date 2024/11/28 12:24
|
||||||
|
* @Description TODO
|
||||||
|
*/
|
||||||
|
public class DriverBean implements Serializable {
|
||||||
|
|
||||||
|
private String driverCode;
|
||||||
|
private String isTaxRegistered;
|
||||||
|
private String taxRegisterStatus;
|
||||||
|
private String taxRegisterStatusDescription;
|
||||||
|
|
||||||
|
public String getDriverCode() {
|
||||||
|
return driverCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDriverCode(String driverCode) {
|
||||||
|
this.driverCode = driverCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsTaxRegistered() {
|
||||||
|
return isTaxRegistered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsTaxRegistered(String isTaxRegistered) {
|
||||||
|
this.isTaxRegistered = isTaxRegistered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaxRegisterStatus() {
|
||||||
|
return taxRegisterStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaxRegisterStatus(String taxRegisterStatus) {
|
||||||
|
this.taxRegisterStatus = taxRegisterStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaxRegisterStatusDescription() {
|
||||||
|
return taxRegisterStatusDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaxRegisterStatusDescription(String taxRegisterStatusDescription) {
|
||||||
|
this.taxRegisterStatusDescription = taxRegisterStatusDescription;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.dahe.mylibrary.net;
|
package com.dahe.mylibrary.net;
|
||||||
|
|
||||||
|
import com.dahe.mylibrary.bean.DriverBean;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,6 +21,16 @@ public class CommonResponseBean<T> implements Serializable {
|
|||||||
private String statusCode;
|
private String statusCode;
|
||||||
private boolean success;
|
private boolean success;
|
||||||
|
|
||||||
|
private DriverBean driver;
|
||||||
|
|
||||||
|
public DriverBean getDriver() {
|
||||||
|
return driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDriver(DriverBean driver) {
|
||||||
|
this.driver = driver;
|
||||||
|
}
|
||||||
|
|
||||||
public String getStatusCode() {
|
public String getStatusCode() {
|
||||||
return statusCode;
|
return statusCode;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user