From f64805032884613563e36445de8255445f583e9c Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 29 Nov 2024 14:50:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=84=8F=E5=BC=80=E5=8F=91=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/ALProcess.java | 25 ++ .../request/bean/newlj/InvoicesBean.java | 135 ++++++++ .../request/net/Api.java | 23 ++ .../request/net/DataManager.java | 1 - .../request/net/JsonInterceptor.java | 73 ++++ .../request/net/RxHttpCallBack.java | 2 +- .../util/NewLJUtils.java | 314 ++++++++++++++---- 7 files changed, 500 insertions(+), 73 deletions(-) create mode 100644 app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/bean/newlj/InvoicesBean.java create mode 100644 app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/JsonInterceptor.java diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/report/ALProcess.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/report/ALProcess.java index d194d96..7bdfaac 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/report/ALProcess.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/report/ALProcess.java @@ -12,7 +12,10 @@ import com.arpa.hndahesudintocctmsdriver.App; import com.arpa.hndahesudintocctmsdriver.BuildConfig; import com.arpa.hndahesudintocctmsdriver.parts.AuthParts; import com.arpa.hndahesudintocctmsdriver.util.MessageUtils; +import com.arpa.hndahesudintocctmsdriver.util.NewLJUtils; import com.arpa.hndahesudintocctmsdriver.util.msg.MsgUtil; +import com.dahe.mylibrary.callback.OnGDDownloadResultListener; +import com.dahe.mylibrary.callback.OnGDResultListener; import com.dahe.mylibrary.utils.ToastUtils; import com.google.gson.Gson; import com.arpa.hndahesudintocctmsdriver.bean.DriverAuthDataBean; @@ -70,6 +73,28 @@ public class ALProcess { new MessageUtils().showCenMessage(con,s1); } }); + + NewLJUtils.getInstance().getToken(con, new OnGDResultListener() { + @Override + public void onSuccess() { + NewLJUtils.getInstance().confirmInvoice(con, new OnGDResultListener() { + @Override + public void onSuccess() { + + } + + @Override + public void onFailure(String var1, String var2) { + + } + }); + } + + @Override + public void onFailure(String var1, String var2) { + + } + }); } public static void getFq(Context con){ diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/bean/newlj/InvoicesBean.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/bean/newlj/InvoicesBean.java new file mode 100644 index 0000000..31a963c --- /dev/null +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/bean/newlj/InvoicesBean.java @@ -0,0 +1,135 @@ +package com.arpa.hndahesudintocctmsdriver.request.bean.newlj; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName InvoicesBean + * @Author john + * @Date 2024/11/29 13:08 + * @Description TODO + */ +public class InvoicesBean implements Serializable { + private String totalPage; + private String totalCount; + private String pageSize; + private String currentPage; + private String sortField; + private String sortDirection; + private List driverInvoices; + + public String getTotalPage() { + return totalPage; + } + + public void setTotalPage(String totalPage) { + this.totalPage = totalPage; + } + + public String getTotalCount() { + return totalCount; + } + + public void setTotalCount(String totalCount) { + this.totalCount = totalCount; + } + + public String getPageSize() { + return pageSize; + } + + public void setPageSize(String pageSize) { + this.pageSize = pageSize; + } + + public String getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(String currentPage) { + this.currentPage = currentPage; + } + + public String getSortField() { + return sortField; + } + + public void setSortField(String sortField) { + this.sortField = sortField; + } + + public String getSortDirection() { + return sortDirection; + } + + public void setSortDirection(String sortDirection) { + this.sortDirection = sortDirection; + } + + public List getDriverInvoices() { + return driverInvoices; + } + + public void setDriverInvoices(List driverInvoices) { + this.driverInvoices = driverInvoices; + } + + public static class DataDTO{ + + private String taxAmount; + private String totalAmount; + private String invoiceReceiverName; + private String totalAmountIncludeTax; + private String driverInvoiceCode; + private String taxRate; + + + public String getTaxAmount() { + return taxAmount; + } + + public void setTaxAmount(String taxAmount) { + this.taxAmount = taxAmount; + } + + public String getTotalAmount() { + return totalAmount; + } + + public void setTotalAmount(String totalAmount) { + this.totalAmount = totalAmount; + } + + public String getInvoiceReceiverName() { + return invoiceReceiverName; + } + + public void setInvoiceReceiverName(String invoiceReceiverName) { + this.invoiceReceiverName = invoiceReceiverName; + } + + public String getTotalAmountIncludeTax() { + return totalAmountIncludeTax; + } + + public void setTotalAmountIncludeTax(String totalAmountIncludeTax) { + this.totalAmountIncludeTax = totalAmountIncludeTax; + } + + public String getDriverInvoiceCode() { + return driverInvoiceCode; + } + + public void setDriverInvoiceCode(String driverInvoiceCode) { + this.driverInvoiceCode = driverInvoiceCode; + } + + public String getTaxRate() { + return taxRate; + } + + public void setTaxRate(String taxRate) { + this.taxRate = taxRate; + } + } +} diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/Api.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/Api.java index fc01482..758a542 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/Api.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/Api.java @@ -5,6 +5,7 @@ import com.arpa.hndahesudintocctmsdriver.BuildConfig; import com.arpa.hndahesudintocctmsdriver.bean.UserBean; import com.arpa.hndahesudintocctmsdriver.request.bean.LoginRegInputBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.InvoiceBean; +import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.InvoicesBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.LjTokenBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.PickupBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.ShipmentStatusBean; @@ -16,6 +17,7 @@ import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; +import retrofit2.http.Path; import retrofit2.http.Query; /** @@ -37,6 +39,13 @@ public interface Api { Observable getToken(@Body LjTokenBean bean); + /** + * 刷新token + * @return + */ + @POST(BASE_URL+"openapi/enterprises/refresh-token/{refreshToken}") + Observable refreshToken(@Path("refreshToken") String refreshToken); + /** * 运单提货 * @param bean @@ -108,6 +117,20 @@ public interface Api { @PUT(BASE_URL+"openapi/confirmInvoice") Observable confirmInvoice(@Body InvoiceBean bean); + /** + * 待同意发票列表获取 + * @param enterpriseCodeParam + * @param driverIdentification + * @param currentPage + * @param pageSize + * @return + */ + @GET(BASE_URL+"openapi/getInvoices") + Observable> getInvoices(@Query("enterpriseCodeParam") String enterpriseCodeParam, + @Query("driverIdentification") String driverIdentification, + @Query("currentPage") int currentPage, + @Query("pageSize") int pageSize); + /** * 获取运单状态 diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/DataManager.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/DataManager.java index d611fa5..0a53ea0 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/DataManager.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/DataManager.java @@ -2,7 +2,6 @@ package com.arpa.hndahesudintocctmsdriver.request.net; import com.dahe.mylibrary.CommonBaseLibrary; -import com.dahe.mylibrary.net.JsonInterceptor; import java.util.concurrent.TimeUnit; diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/JsonInterceptor.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/JsonInterceptor.java new file mode 100644 index 0000000..d497dff --- /dev/null +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/JsonInterceptor.java @@ -0,0 +1,73 @@ +package com.arpa.hndahesudintocctmsdriver.request.net; + +import android.text.TextUtils; +import android.util.Log; + +import com.arpa.hndahesudintocctmsdriver.App; +import com.arpa.hndahesudintocctmsdriver.util.NewLJUtils; +import com.dahe.mylibrary.net.ResultException; + +import org.json.JSONObject; + +import java.io.IOException; +import java.nio.charset.Charset; + +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import okio.Buffer; +import okio.BufferedSource; + +/** + * json的Interceptor + */ + +public class JsonInterceptor implements Interceptor { + private static final String TAG = "JsonInterceptor"; + + public JsonInterceptor() { + } + + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + Response response = chain.proceed(request); + ResponseBody responseBody = response.body(); + //为了不消耗buffer,我们这里使用source先获得buffer对象,然后clone()后使用 + BufferedSource source = responseBody.source(); + source.request(Long.MAX_VALUE); // Buffer the entire body. + //获得返回的数据 + Buffer buffer = source.buffer(); + //使用前clone()下,避免直接消耗 + String responseBodyStr = buffer.clone().readString(Charset.forName("UTF-8")); + Log.i(TAG, "result-body= " + responseBodyStr); + try { + +// if (401==response.code()){ +// NewLJUtils.getInstance().refreshToken(App.getApp()); +// } + + + JSONObject jsonObject = new JSONObject(responseBodyStr); + String str = jsonObject.optString("data"); + int code = jsonObject.optInt("code"); + if (-1 == code) { + jsonObject.put("data", new JSONObject()); + throw new ResultException(); + } else { + if (TextUtils.isEmpty(str)) { + jsonObject.put("data", new JSONObject()); + } + } + + String data = jsonObject.toString(); + responseBody = ResponseBody.create(MediaType.parse("application/json; charset=utf-8"), data); + } catch (Exception e) { + e.printStackTrace(); + } + response = response.newBuilder().body(responseBody).build(); + return response; + } +} diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/RxHttpCallBack.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/RxHttpCallBack.java index 2de6ced..99f67fe 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/RxHttpCallBack.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/request/net/RxHttpCallBack.java @@ -88,7 +88,7 @@ public abstract class RxHttpCallBack { } if ("401".equals(t.getCode())) { - NewLJUtils.getInstance().getToken(mContext); + NewLJUtils.getInstance().refreshToken(mContext); // UiAuxiliary.delLogin(mContext); // Intent intent = new Intent(mContext, MainActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/util/NewLJUtils.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/util/NewLJUtils.java index f93aebf..f0d0869 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/util/NewLJUtils.java +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/util/NewLJUtils.java @@ -10,12 +10,16 @@ import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; +import com.arpa.hndahesudintocctmsdriver.App; +import com.arpa.hndahesudintocctmsdriver.bean.DriverAuthDataBean; import com.arpa.hndahesudintocctmsdriver.bean.GDImage; import com.arpa.hndahesudintocctmsdriver.bean.GDLocation; import com.arpa.hndahesudintocctmsdriver.bean.IsAuthCardBean; import com.arpa.hndahesudintocctmsdriver.constant.NewLJConstant; +import com.arpa.hndahesudintocctmsdriver.parts.AuthParts; import com.arpa.hndahesudintocctmsdriver.request.AuthRequest; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.InvoiceBean; +import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.InvoicesBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.LjTokenBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.PickupBean; import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.ShipmentStatusBean; @@ -73,11 +77,30 @@ public class NewLJUtils { public void onSuccess(CommonResponseBean t) { super.onSuccess(t); SPUtils.put(ctx, NEW_LJ_TOKEN, t.getToken()); + refreshToken(ctx); } })); } - public void getToken(Context ctx,OnGDResultListener listener) { + + /** + * 刷新token + * @param ctx + */ + public void refreshToken(Context ctx){ + String token = SPUtils.get(ctx, NEW_LJ_TOKEN, "").toString(); + DataManager.getInstance().refreshToken(token) + .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver(ctx, new RxHttpCallBack() { + @Override + public void onSuccess(CommonResponseBean t) { + super.onSuccess(t); + SPUtils.put(ctx, NEW_LJ_TOKEN, t.getToken()); + } + })); + } + + public void getToken(Context ctx, OnGDResultListener listener) { LjTokenBean ljTokenBean = new LjTokenBean(); ljTokenBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE); ljTokenBean.setEnterpriseIdentity(NewLJConstant.ENTER_PRISE_IDENTITY); @@ -90,7 +113,8 @@ public class NewLJUtils { public void onSuccess(CommonResponseBean t) { super.onSuccess(t); SPUtils.put(ctx, NEW_LJ_TOKEN, t.getToken()); - if (listener!=null) + refreshToken(ctx); + if (listener != null) listener.onSuccess(); } })); @@ -410,35 +434,158 @@ public class NewLJUtils { } + /** + * 获取发票列表 + * + * @param ctx + * @param listener + */ + public void getInvoices(Context ctx, OnGDResultListener listener) { + DriverAuthDataBean auth = AuthParts.getAuth(ctx); + if (auth == null) { + return; + } + + DataManager.getInstance().getInvoices(NewLJConstant.ENTER_PRISE_CODE, auth.getData().getIdcard(), 1, 100) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver(ctx, new RxHttpCallBack>() { + @Override + public void onSuccess(CommonResponseBean> t) { + super.onSuccess(t); + if (t.getData().getData().getDriverInvoices().size() > 0) { + confirmInvoice(ctx, new OnGDResultListener() { + @Override + public void onSuccess() { + + } + + @Override + public void onFailure(String var1, String var2) { + Log.e("NewLJUtils", var1 + var2); + } + }); + } + + } + + @Override + public void onCodeError(Context mContext, CommonResponseBean> t) { + super.onCodeError(mContext, t); + Log.e("NewLJUtils", t.getMessage()); + } + })); + } + + /** * 同意发票申请 * * @param ctx - * @param shipmentCode - * @param invoiceBean */ - public void confirmInvoice(Context ctx, String shipmentCode, InvoiceBean invoiceBean, OnGDResultListener listener) { + public void confirmInvoice(Context ctx, OnGDResultListener listener) { + DriverAuthDataBean auth = AuthParts.getAuth(ctx); + if (auth == null) { + return; + } + searchDriver(ctx, auth.getData().getIdcard(), new OnGDDownloadResultListener() { + @Override + public void onSuccess(String var1) { + InvoiceBean invoiceBean = new InvoiceBean(); + invoiceBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE); + invoiceBean.setDriverInvoiceCode(var1); + invoiceBean.setDriverIdentification(auth.getData().getIdcard()); + DataManager.getInstance().confirmInvoice(invoiceBean) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver(ctx, new RxHttpCallBack() { + @Override + public void onSuccess(CommonResponseBean t) { + super.onSuccess(t); + if (listener != null) { + listener.onSuccess(); + } + } + + @Override + public void onCodeError(Context mContext, CommonResponseBean t) { + super.onCodeError(mContext, t); + if (listener != null) { + listener.onFailure(t.getCode() + "", t.getMessage()); + } + } + })); + } + + @Override + public void onFailure(String var1, String var2) { + + } + }); + + + //查询身份证信息 +// new AuthRequest().getCard(ctx, new Handler(msg -> { +// switch (msg.what) { +// case RequsetCodeConstants.ERROR: +// Toast.makeText(ctx, RequsetCodeConstants.FEEDBACK_TEXT, Toast.LENGTH_SHORT).show(); +// break; +// case RequsetCodeConstants.UNKONWN: +// Toast.makeText(ctx, RequsetCodeConstants.UNKONWN_TEXT, Toast.LENGTH_SHORT).show(); +// break; +// case RequsetCodeConstants.SERVER_ERROR: +// Toast.makeText(ctx, RequsetCodeConstants.SERVER_ERROR_TEXT, Toast.LENGTH_SHORT).show(); +// break; +// case RequsetCodeConstants.GATEWAY_ERROR: +// Toast.makeText(ctx, 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(ctx, iacb.getData().getIdcard(), new OnGDDownloadResultListener() { +// @Override +// public void onSuccess(String var1) { +// InvoiceBean invoiceBean = new InvoiceBean(); +// invoiceBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE); +// invoiceBean.setDriverInvoiceCode(var1); +// invoiceBean.setDriverIdentification(iacb.getData().getIdcard()); +// DataManager.getInstance().confirmInvoice(invoiceBean) +// .subscribeOn(Schedulers.io()) +// .observeOn(AndroidSchedulers.mainThread()) +// .subscribe(new BaseObserver(ctx, new RxHttpCallBack() { +// @Override +// public void onSuccess(CommonResponseBean t) { +// super.onSuccess(t); +// if (listener != null) { +// listener.onSuccess(); +// } +// } +// +// @Override +// public void onCodeError(Context mContext, CommonResponseBean t) { +// super.onCodeError(mContext, t); +// if (listener != null) { +// listener.onFailure(t.getCode() + "", t.getMessage()); +// } +// } +// })); +// } +// +// @Override +// public void onFailure(String var1, String var2) { +// +// } +// }); +// } else { +// Toast.makeText(ctx, "缺少身份证信息", Toast.LENGTH_SHORT).show(); +// } +// break; +// } +// return false; +// })); - DataManager.getInstance().confirmInvoice(invoiceBean) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new BaseObserver(ctx, new RxHttpCallBack() { - @Override - public void onSuccess(CommonResponseBean t) { - super.onSuccess(t); - if (listener != null) { - listener.onSuccess(); - } - } - @Override - public void onCodeError(Context mContext, CommonResponseBean t) { - super.onCodeError(mContext, t); - if (listener != null) { - listener.onFailure(t.getCode() + "", t.getMessage()); - } - } - })); } @@ -502,51 +649,76 @@ public class NewLJUtils { * @param act */ public void startLocationService(AppCompatActivity act) { - //查询身份证信息 - new AuthRequest().getCard(act, new Handler(msg -> { - switch (msg.what) { - case RequsetCodeConstants.ERROR: - Toast.makeText(act, RequsetCodeConstants.FEEDBACK_TEXT, Toast.LENGTH_SHORT).show(); - break; - 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; + DriverAuthDataBean auth = AuthParts.getAuth(act); + if (auth == null) { + return; + } + searchDriver(act, auth.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); + } } - return false; - })); + + @Override + public void onFailure(String var1, String var2) { + + } + }); + + + //查询身份证信息 +// new AuthRequest().getCard(act, new Handler(msg -> { +// switch (msg.what) { +// case RequsetCodeConstants.ERROR: +// Toast.makeText(act, RequsetCodeConstants.FEEDBACK_TEXT, Toast.LENGTH_SHORT).show(); +// break; +// 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; +// })); } @@ -562,7 +734,7 @@ public class NewLJUtils { /** * 查询司机 */ - public void searchDriver(Context ctx,String idCard, OnGDDownloadResultListener listener) { + public void searchDriver(Context ctx, String idCard, OnGDDownloadResultListener listener) { DataManager.getInstance().searchDriver(idCard) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -580,8 +752,8 @@ public class NewLJUtils { @Override public void onCodeError(Context mContext, CommonResponseBean t) { super.onCodeError(mContext, t); - if (listener!=null) - listener.onFailure(t.getCode(),t.getMessage()); + if (listener != null) + listener.onFailure(t.getCode(), t.getMessage()); } })); }