760 lines
31 KiB
Java
760 lines
31 KiB
Java
package com.arpa.hndahesudintocctmsdriver.util;
|
|
|
|
import static com.dahe.mylibrary.utils.BaseSPUtils.NEW_LJ_TOKEN;
|
|
|
|
import android.content.Context;
|
|
import android.os.Handler;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
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;
|
|
import com.arpa.hndahesudintocctmsdriver.request.bean.newlj.UpimgBean;
|
|
import com.arpa.hndahesudintocctmsdriver.request.net.BaseObserver;
|
|
import com.arpa.hndahesudintocctmsdriver.request.net.DataManager;
|
|
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.OnGDResultListener;
|
|
import com.dahe.mylibrary.net.CommonResponseBean;
|
|
import com.dahe.mylibrary.utils.ToastUtils;
|
|
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.schedulers.Schedulers;
|
|
|
|
/**
|
|
* @ClassName NewLJUtils
|
|
* @Author john
|
|
* @Date 2024/11/25 09:53
|
|
* @Description TODO
|
|
*/
|
|
public class NewLJUtils {
|
|
|
|
|
|
private static class SingletonHolder {
|
|
private static final NewLJUtils INSTANCE = new NewLJUtils();
|
|
}
|
|
|
|
private NewLJUtils() {
|
|
}
|
|
|
|
public static final NewLJUtils getInstance() {
|
|
return SingletonHolder.INSTANCE;
|
|
}
|
|
|
|
public void getToken(Context ctx) {
|
|
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());
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 刷新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<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean<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);
|
|
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();
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单提货
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param location
|
|
*/
|
|
public void pickUp(Context ctx, String shipmentCode, GDLocation location, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (Double.isNaN(location.getBaiduLatitude()) || Double.isNaN(location.getBaiduLongitude())) {
|
|
ToastUtils.showToast(ctx, "经纬度不能为空");
|
|
return;
|
|
}
|
|
PickupBean pickupBean = new PickupBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setLocation(location);
|
|
DataManager.getInstance().pickup(pickupBean)
|
|
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单卸货
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param location
|
|
*/
|
|
public void unload(Context ctx, String shipmentCode, GDLocation location, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (Double.isNaN(location.getBaiduLatitude()) || Double.isNaN(location.getBaiduLongitude())) {
|
|
ToastUtils.showToast(ctx, "经纬度不能为空");
|
|
return;
|
|
}
|
|
|
|
PickupBean pickupBean = new PickupBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setLocation(location);
|
|
DataManager.getInstance().unload(pickupBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单签收
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param location
|
|
*/
|
|
public void sign(Context ctx, String shipmentCode, GDLocation location, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (Double.isNaN(location.getBaiduLatitude()) || Double.isNaN(location.getBaiduLongitude())) {
|
|
ToastUtils.showToast(ctx, "经纬度不能为空");
|
|
return;
|
|
}
|
|
|
|
PickupBean pickupBean = new PickupBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setLocation(location);
|
|
DataManager.getInstance().sign(pickupBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单回单
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param location
|
|
*/
|
|
public void pod(Context ctx, String shipmentCode, GDLocation location, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (Double.isNaN(location.getBaiduLatitude()) || Double.isNaN(location.getBaiduLongitude())) {
|
|
ToastUtils.showToast(ctx, "经纬度不能为空");
|
|
return;
|
|
}
|
|
|
|
PickupBean pickupBean = new PickupBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setLocation(location);
|
|
DataManager.getInstance().pod(pickupBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单提货照片上传
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param imageDTO
|
|
*/
|
|
public void uploadPickupImage(Context ctx, String shipmentCode, GDImage imageDTO, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (TextUtils.isEmpty(imageDTO.getFileName())) {
|
|
ToastUtils.showToast(ctx, "照片不能为空");
|
|
return;
|
|
}
|
|
|
|
UpimgBean pickupBean = new UpimgBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setImage(imageDTO);
|
|
DataManager.getInstance().uploadPickupImage(pickupBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单卸货照片上传
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param imageDTO
|
|
*/
|
|
public void uploadUnloadImage(Context ctx, String shipmentCode, GDImage imageDTO, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (TextUtils.isEmpty(imageDTO.getFileName())) {
|
|
ToastUtils.showToast(ctx, "照片不能为空");
|
|
return;
|
|
}
|
|
|
|
UpimgBean pickupBean = new UpimgBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setImage(imageDTO);
|
|
DataManager.getInstance().uploadUnloadImage(pickupBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单回单照片上传
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
* @param imageDTO
|
|
*/
|
|
public void uploadPODImage(Context ctx, String shipmentCode, GDImage imageDTO, OnGDResultListener listener) {
|
|
if (TextUtils.isEmpty(shipmentCode)) {
|
|
ToastUtils.showToast(ctx, "运单号不能为空");
|
|
return;
|
|
}
|
|
|
|
if (TextUtils.isEmpty(imageDTO.getFileName())) {
|
|
ToastUtils.showToast(ctx, "照片不能为空");
|
|
return;
|
|
}
|
|
|
|
UpimgBean pickupBean = new UpimgBean();
|
|
pickupBean.setShipmentCode(shipmentCode);
|
|
pickupBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
pickupBean.setImage(imageDTO);
|
|
DataManager.getInstance().uploadPODImage(pickupBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取发票列表
|
|
*
|
|
* @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<CommonResponseBean<InvoicesBean>>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean<CommonResponseBean<InvoicesBean>> 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<CommonResponseBean<InvoicesBean>> t) {
|
|
super.onCodeError(mContext, t);
|
|
// Log.e("NewLJUtils", t.getMsg().toString());
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/**
|
|
* 同意发票申请
|
|
*
|
|
* @param ctx
|
|
*/
|
|
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<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":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<CommonResponseBean>() {
|
|
// @Override
|
|
// public void onSuccess(CommonResponseBean t) {
|
|
// super.onSuccess(t);
|
|
// if (listener != null) {
|
|
// listener.onSuccess();
|
|
// }
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void onCodeError(Context mContext, CommonResponseBean<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;
|
|
// }));
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 运单状态查询
|
|
*
|
|
* @param ctx
|
|
* @param shipmentCode
|
|
*/
|
|
public void getShipmentStatus(Context ctx, String shipmentCode, OnGDDownloadResultListener listener) {
|
|
ShipmentStatusBean shipmentStatusBean = new ShipmentStatusBean();
|
|
shipmentStatusBean.setShipmentCode(shipmentCode);
|
|
shipmentStatusBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
DataManager.getInstance().getShipmentStatus(shipmentStatusBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
if (listener != null) {
|
|
listener.onSuccess(t.getStatusCode());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
if (listener != null) {
|
|
listener.onFailure(t.getCode() + "", TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
public void getPODImageNames(Context ctx, String shipmentCode) {
|
|
ShipmentStatusBean shipmentStatusBean = new ShipmentStatusBean();
|
|
shipmentStatusBean.setShipmentCode(shipmentCode);
|
|
shipmentStatusBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
|
DataManager.getInstance().getPODImageNames(shipmentStatusBean)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new BaseObserver(ctx, new RxHttpCallBack<CommonResponseBean>() {
|
|
@Override
|
|
public void onSuccess(CommonResponseBean t) {
|
|
super.onSuccess(t);
|
|
System.out.println("sadf");
|
|
}
|
|
|
|
@Override
|
|
public void onCodeError(Context mContext, CommonResponseBean<CommonResponseBean> t) {
|
|
super.onCodeError(mContext, t);
|
|
System.out.println("sadf");
|
|
}
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* 开启位置上传
|
|
*
|
|
* @param act
|
|
*/
|
|
public void startLocationService(AppCompatActivity act) {
|
|
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);
|
|
}
|
|
}
|
|
|
|
@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;
|
|
// }));
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* 关闭定位服务
|
|
*/
|
|
public void 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(), TextUtils.isEmpty(t.getMessage())?"运单操作异常":t.getMessage());
|
|
}
|
|
}));
|
|
}
|
|
|
|
}
|