Compare commits
4 Commits
5a9ada8d24
...
a20419f577
Author | SHA1 | Date | |
---|---|---|---|
a20419f577 | |||
a3a45d211b | |||
1ded7d3719 | |||
a3cae11a8a |
@ -94,8 +94,8 @@ android {
|
||||
JPUSH_APPKEY : "fba6f55621c670d8c1fe9191",
|
||||
//暂时填写默认值即可.
|
||||
JPUSH_CHANNEL: "developer-n"]
|
||||
buildConfigField("String", "OPEN_AL_URL", "\"https://oapi-staging.alct56.com\"")
|
||||
buildConfigField("String", "BASE_URL", "\"http://192.168.1.118:8082/devApi/\"")
|
||||
buildConfigField("String", "BASE_LJ_URL", "\"http://api.kehui56.cn/api/v1/\"")
|
||||
// buildConfigField("String", "BASE_URL", "\"http://192.168.1.118:8080/devApi/\"")
|
||||
// buildConfigField("String", "BASE_URL", "\"http://platform.test.v2.dahehuoyun.com/devApi/\"")
|
||||
buildConfigField "boolean", "isTest", "true"
|
||||
@ -111,8 +111,8 @@ android {
|
||||
JPUSH_APPKEY : "fba6f55621c670d8c1fe9191",
|
||||
//暂时填写默认值即可.
|
||||
JPUSH_CHANNEL: "developer-default"]
|
||||
buildConfigField("String", "OPEN_AL_URL", "\"https://oapi.alct56.com\"")
|
||||
buildConfigField("String", "BASE_URL", "\"http://app.dahehuoyun.com/api/\"")
|
||||
buildConfigField("String", "BASE_LJ_URL", "\"https://api.kehui56.com/api/v1/\"")
|
||||
buildConfigField "boolean", "isTest", "false"
|
||||
resValue "string", "appName", "司机端"
|
||||
}
|
||||
@ -179,10 +179,10 @@ dependencies {
|
||||
|
||||
//安联
|
||||
//当引入的与之前引入的库有重复冲突部分的时候,使用compileOnly
|
||||
implementation files('libs\\mdp_sdk.jar')
|
||||
implementation 'com.loopj.android:android-async-http:1.4.9'
|
||||
implementation 'com.j256.ormlite:ormlite-android:4.48'
|
||||
implementation 'com.j256.ormlite:ormlite-core:4.48'
|
||||
// implementation files('libs\\mdp_sdk.jar')
|
||||
// implementation 'com.loopj.android:android-async-http:1.4.9'
|
||||
// implementation 'com.j256.ormlite:ormlite-android:4.48'
|
||||
// implementation 'com.j256.ormlite:ormlite-core:4.48'
|
||||
implementation 'com.github.hotchemi:permissionsdispatcher:2.3.1'
|
||||
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.1'
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -91,13 +91,13 @@
|
||||
android:name="android.notch_support"
|
||||
android:value="true" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.amap.api.v2.apikey"
|
||||
android:value="78019612271411eca3af34db91930620" />
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="com.amap.api.v2.apikey"-->
|
||||
<!-- android:value="78019612271411eca3af34db91930620" />-->
|
||||
|
||||
<service
|
||||
android:name="com.amap.api.location.APSService"
|
||||
android:foregroundServiceType="location" />
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.amap.api.location.APSService"-->
|
||||
<!-- android:foregroundServiceType="location" />-->
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
|
@ -8,7 +8,6 @@ import android.os.Process
|
||||
import android.util.Log
|
||||
import cn.jiguang.api.utils.JCollectionAuth
|
||||
import cn.jpush.android.api.JPushInterface
|
||||
import com.alct.mdp.MDPLocationCollectionManager
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.net.Api
|
||||
import com.arpa.hndahesudintocctmsdriver.oss.OssServiceUtil
|
||||
@ -98,7 +97,7 @@ class App : Application() {
|
||||
//安联初始化
|
||||
if (packageName == getCurrentProcessName(this)) {
|
||||
//Log.e("--使用的测试环境--",BuildConfig.OPEN_API_URL);
|
||||
MDPLocationCollectionManager.initialize(applicationContext, BuildConfig.OPEN_AL_URL)
|
||||
// MDPLocationCollectionManager.initialize(applicationContext, BuildConfig.OPEN_AL_URL)
|
||||
// MDPLocationCollectionManager.initServiceProcessProguard(applicationContext) // 保活代码
|
||||
// startService(Intent(this, PlayerMusicService::class.java)) // 保活代码
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.base
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig
|
||||
|
||||
/**
|
||||
* @author hlh
|
||||
* @version 1.0.0
|
||||
* @date 2022/1/10 11:34
|
||||
* @description:交通厅参数
|
||||
*/
|
||||
object NewLJConstant {
|
||||
const val ENTER_PRISE_CODE: String = "E0019169"
|
||||
|
||||
val ENTER_PRISE_IDENTITY: String = if (BuildConfig.isTest) "95033cc3492e420d83d7f09eea1400ac" else "9179388b0e0847e1862d6400f9cbc778"
|
||||
|
||||
val ENTER_PRISE_KEY: String =
|
||||
if (BuildConfig.isTest) "e9844a9b0bba417e89cb8623489abd2f" else "156d724e9701420198fcbd52cb1ca529"
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.bean
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* @ClassName NewLjBean
|
||||
* @Author john
|
||||
* @Date 2025/1/21 09:16
|
||||
* @Description TODO
|
||||
*/
|
||||
data class LjTokenBean(
|
||||
var enterpriseCode: String = "",
|
||||
var enterpriseIdentity: String = "",
|
||||
var enterpriseKey: String = ""
|
||||
)
|
||||
|
||||
|
||||
data class PickupBean(
|
||||
var shipmentCode: String = "", var enterpriseCode: String = "", var location: GDLocation? = null
|
||||
)
|
||||
|
||||
data class GDLocation(
|
||||
var baiduLongitude: Double = 0.0,
|
||||
var baiduLatitude: Double = 0.0,
|
||||
var location: String = "",
|
||||
var time: String = ""
|
||||
)
|
||||
|
||||
data class UpimgBean(
|
||||
var shipmentCode: String = "",
|
||||
var enterpriseCode: String = "",
|
||||
var image: GDImage? = null
|
||||
)
|
||||
|
||||
data class GDImage(
|
||||
var fileName: String = "",
|
||||
var fileData: String = "",
|
||||
var fileExt: String = "",
|
||||
var imageTakenDate: String = "",
|
||||
var baiduLongitude: Double = 0.0,
|
||||
var baiduLatitude: Double = 0.0,
|
||||
var location: String = "",
|
||||
var time: String = ""
|
||||
)
|
||||
|
||||
data class InvoiceBean(
|
||||
var driverIdentification: String = "",
|
||||
var driverInvoiceCode: String = "",
|
||||
var enterpriseCode: String = ""
|
||||
)
|
||||
|
||||
data class ShipmentStatusBean(var shipmentCode: String = "", var enterpriseCode: String = "")
|
||||
|
||||
|
||||
data class InvoicesBean(
|
||||
var totalPage: String? = null,
|
||||
var totalCount: String? = null,
|
||||
var pageSize: String? = null,
|
||||
var currentPage: String? = null,
|
||||
var sortField: String? = null,
|
||||
var sortDirection: String? = null,
|
||||
var driverInvoices: List<DataDTO>? = null
|
||||
) : Serializable {
|
||||
|
||||
data class DataDTO(
|
||||
var taxAmount: String? = null,
|
||||
var totalAmount: String? = null,
|
||||
var invoiceReceiverName: String? = null,
|
||||
var totalAmountIncludeTax: String? = null,
|
||||
var driverInvoiceCode: String? = null,
|
||||
var taxRate: String? = null
|
||||
)
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.callback
|
||||
|
||||
/**
|
||||
* @ClassName OnGDDownloadResultListener
|
||||
* @Author john
|
||||
* @Date 2025/1/21 10:40
|
||||
* @Description TODO
|
||||
*/
|
||||
interface OnGDDownloadResultListener {
|
||||
fun onSuccess(var1: String)
|
||||
|
||||
fun onFailure(code: String, message: String)
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.callback
|
||||
|
||||
/**
|
||||
* @ClassName OnGDResultListener
|
||||
* @Author john
|
||||
* @Date 2025/1/21 10:14
|
||||
* @Description TODO
|
||||
*/
|
||||
interface OnGDResultListener {
|
||||
fun onSuccess()
|
||||
|
||||
fun onFailure(code: String, message: String)
|
||||
}
|
@ -1,26 +1,36 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.net
|
||||
|
||||
import com.arpa.glex.bean.*
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.AppVersion
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.AuthTeamBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.CaptainBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.CarBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.CarDetail
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.CashConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.DiCarColor
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.DriverBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.FaceBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.InviteRecord
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.InvoiceBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.InvoicesBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.LjTokenBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.MessageBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.MyJtt
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.MyLocation
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.OcrPersonBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.OrderChild
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.OrderDetailBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.OssBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.PickupBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.ProBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.QueDetail
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.QuestionBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.RateBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.ShipmentStatusBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpBankInfoBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpCaptain
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpCashBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpDriverCar
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpDriverInfoBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpDrivingInfoBean
|
||||
@ -32,19 +42,18 @@ import com.arpa.hndahesudintocctmsdriver.bean.UpPicBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpQualiInfoBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpRate
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpRoadInfoBean
|
||||
import com.arpa.glex.bean.*
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.CashConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.MyJtt
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.MyLocation
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpCashBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpimgBean
|
||||
import com.arpa.mylibrary.net.CommonResponseBean
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import okhttp3.MultipartBody
|
||||
import retrofit2.Call
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Multipart
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.PUT
|
||||
import retrofit2.http.Part
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Query
|
||||
|
||||
|
||||
@ -662,10 +671,149 @@ interface Api {
|
||||
@GET(BASE_URL + "driver/message/read")
|
||||
fun messageRead(@Query("messageId") messageId: String): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
|
||||
/*********安联开始***********/
|
||||
|
||||
@POST(BASE_LJ_URL + "openapi/enterprises/login")
|
||||
fun getToken(@Body bean: LjTokenBean?): Observable<CommonResponseBean<Any>>
|
||||
|
||||
@POST(BASE_LJ_URL + "openapi/enterprises/login")
|
||||
fun getRefreshToken(@Body bean: LjTokenBean?): Call<HashMap<String, String>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单提货
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/pickup")
|
||||
fun pickup(@Body bean: PickupBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单卸货
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/unload")
|
||||
fun unload(@Body bean: PickupBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单签收
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/sign")
|
||||
fun sign(@Body bean: PickupBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单回单
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/pod")
|
||||
fun pod(@Body bean: PickupBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单提货照片上传
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/uploadPickupImage")
|
||||
fun uploadPickupImage(@Body bean: UpimgBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单卸货照片上传
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/uploadUnloadImage")
|
||||
fun uploadUnloadImage(@Body bean: UpimgBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 运单回单照片上传
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "openapi/shipments/uploadPODImage")
|
||||
fun uploadPODImage(@Body bean: UpimgBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 同意发票申请
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@PUT(BASE_LJ_URL + "openapi/confirmInvoice")
|
||||
fun confirmInvoice(@Body bean: InvoiceBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
/**
|
||||
* 待同意发票列表获取
|
||||
* @param enterpriseCodeParam
|
||||
* @param driverIdentification
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@GET(BASE_LJ_URL + "openapi/getInvoices")
|
||||
fun getInvoices(
|
||||
@Query("enterpriseCodeParam") enterpriseCodeParam: String?,
|
||||
@Query("driverIdentification") driverIdentification: String?,
|
||||
@Query("currentPage") currentPage: Int,
|
||||
@Query("pageSize") pageSize: Int
|
||||
): Observable<CommonResponseBean<InvoicesBean>>
|
||||
|
||||
|
||||
/**
|
||||
* 获取运单状态
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@POST(BASE_LJ_URL + "/openapi/getShipmentStatus")
|
||||
fun getShipmentStatus(@Body bean: ShipmentStatusBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
@POST(BASE_LJ_URL + "/openapi/shipments/getPODImageNames")
|
||||
fun getPODImageNames(@Body bean: ShipmentStatusBean): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
@GET("$BASE_LJ_URL/openapi/drivers")
|
||||
fun searchDriver(@Query("identityNo") identityNo: String): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/**
|
||||
* 司机车辆绑定关系
|
||||
* @param identityNo
|
||||
* @return
|
||||
*/
|
||||
@GET(BASE_LJ_URL + "openapi/drivers/{identityNo}/trucks")
|
||||
fun trucks(@Path("identityNo") identityNo: String): Observable<CommonResponseBean<Any>>
|
||||
|
||||
|
||||
/*********安联结束***********/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
// String BASE_URL = "https://tmstest.dahehuoyun.com/";
|
||||
const val BASE_URL = BuildConfig.BASE_URL
|
||||
|
||||
const val BASE_LJ_URL: String =BuildConfig.BASE_LJ_URL
|
||||
|
||||
//获取版本
|
||||
const val VERSION = BASE_URL + "app/version"
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.arpa.hndahesudintocctmsdriver.net
|
||||
|
||||
import com.arpa.mylibrary.CommonBaseLibrary
|
||||
import com.arpa.mylibrary.base.BaseSingNoParam
|
||||
import com.arpa.mylibrary.net.JsonInterceptor
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.ObservableTransformer
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
|
@ -0,0 +1,120 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.net;
|
||||
|
||||
import static com.arpa.mylibrary.utils.BaseSPUtils.NEW_LJ_TOKEN;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig;
|
||||
import com.arpa.hndahesudintocctmsdriver.base.App;
|
||||
import com.arpa.hndahesudintocctmsdriver.base.NewLJConstant;
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.LjTokenBean;
|
||||
import com.arpa.hndahesudintocctmsdriver.utils.SPUtils;
|
||||
import com.arpa.mylibrary.CommonBaseLibrary;
|
||||
import com.arpa.mylibrary.net.ResultException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import kotlin.jvm.Synchronized;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
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 {
|
||||
|
||||
JSONObject jsonObject = new JSONObject(responseBodyStr);
|
||||
String str = jsonObject.optString("data");
|
||||
int code = jsonObject.optInt("code");
|
||||
String url = request.url().url().toString();
|
||||
|
||||
//判断是否是路交接口
|
||||
if (url.startsWith(BuildConfig.BASE_LJ_URL)){
|
||||
if (401 == code) {
|
||||
refreshToken();
|
||||
response.close();
|
||||
try {
|
||||
return chain.proceed(request);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (-1 == code) {
|
||||
jsonObject.put("data", new JSONObject());
|
||||
throw new ResultException();
|
||||
} else {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
jsonObject.put("data", new JSONObject());
|
||||
}
|
||||
}
|
||||
}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;
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private void refreshToken() throws IOException {
|
||||
Api api = CommonBaseLibrary.getRetrofit().newBuilder()
|
||||
.client(new OkHttpClient.Builder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.build())
|
||||
// .addNetworkInterceptor(new TokenInterceptor())
|
||||
.build().create(Api.class);
|
||||
LjTokenBean ljTokenBean = new LjTokenBean();
|
||||
ljTokenBean.setEnterpriseCode(NewLJConstant.ENTER_PRISE_CODE);
|
||||
ljTokenBean.setEnterpriseIdentity(NewLJConstant.INSTANCE.getENTER_PRISE_IDENTITY());
|
||||
ljTokenBean.setEnterpriseKey(NewLJConstant.INSTANCE.getENTER_PRISE_KEY());
|
||||
retrofit2.Response<HashMap<String, String>> execute = api.getRefreshToken(ljTokenBean).execute();
|
||||
if (execute.body() != null) {
|
||||
String refreshToken = execute.body().get("token");
|
||||
SPUtils.put(App.Companion.getApp(), NEW_LJ_TOKEN, refreshToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.third
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.alct.mdp.MDPLocationCollectionManager
|
||||
import com.alct.mdp.callback.OnDownloadResultListener
|
||||
import com.alct.mdp.callback.OnResultListener
|
||||
import com.alct.mdp.model.Identity
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.FqBean
|
||||
import com.arpa.hndahesudintocctmsdriver.utils.SPUtils
|
||||
import com.google.gson.Gson
|
||||
|
||||
/**
|
||||
* @author hlh
|
||||
* @version 1.0.0
|
||||
* @date 2021/8/16 10:35
|
||||
* @description:安联流程
|
||||
*/
|
||||
class ALProcess {
|
||||
companion object {
|
||||
//企业代码
|
||||
private const val ENTERPRISE_CODE = "E0019169"
|
||||
|
||||
//企业app的身份码
|
||||
private const val APP_IDENTITY = "b4a472a025e443b383970cdd5465552e"
|
||||
|
||||
//企业app验证码
|
||||
private const val APP_KEY = "b948efbb4c2a4ba0805c534f2fba0c89"
|
||||
|
||||
//企业代码-测试
|
||||
private const val ENTERPRISE_CODE_TEXT = "E0019093"
|
||||
|
||||
//企业app的身份码-测试
|
||||
private const val APP_IDENTITY_TEXT = "a15b4ba5bd2542cc9a6bea9bdadf9ef9"
|
||||
|
||||
//企业app验证码-测试
|
||||
private const val APP_KEY_TEXT = "07a6256cad5642138ed6e962a5a157be"
|
||||
fun verification(con: Context?) {
|
||||
val userInfo = SPUtils.instance.getUserInfo(con)
|
||||
val idy = Identity()
|
||||
//企业代码
|
||||
idy.enterpriseCode = if (BuildConfig.isTest) ENTERPRISE_CODE_TEXT else ENTERPRISE_CODE
|
||||
//企业app的身份码
|
||||
idy.appIdentity = if (BuildConfig.isTest) APP_IDENTITY_TEXT else APP_IDENTITY
|
||||
//企业app验证码
|
||||
idy.appKey = if (BuildConfig.isTest) APP_KEY_TEXT else APP_KEY
|
||||
//司机身份证
|
||||
idy.driverIdentity = userInfo?.idcard
|
||||
// idy.driverIdentity = "410423199703041014"
|
||||
MDPLocationCollectionManager.register(con, idy, object : OnResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("--success--", "验证成功")
|
||||
getFq(con)
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("--error--", s + s1 + "")
|
||||
// new MessageUtils().showCenMessage(con,s1);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getFq(con: Context?) {
|
||||
MDPLocationCollectionManager.getInvoices(
|
||||
con,
|
||||
100,
|
||||
1,
|
||||
object : OnDownloadResultListener {
|
||||
override fun onSuccess(o: Any) {
|
||||
Log.e("--获取发票列表成功--", Gson().toJson(o))
|
||||
try {
|
||||
val fb = Gson().fromJson(Gson().toJson(o), FqBean::class.java)
|
||||
applyFq(con, fb)
|
||||
} catch (e: Exception) {
|
||||
Log.e("--失败--", "数据解析失败")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("--获取发票列表失败--", s + s1 + "")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun applyFq(con: Context?, fb: FqBean) {
|
||||
for (driverInvoice in fb.driverInvoices) {
|
||||
MDPLocationCollectionManager.confirmInvoice(
|
||||
con,
|
||||
if (BuildConfig.isTest) ENTERPRISE_CODE_TEXT else ENTERPRISE_CODE,
|
||||
driverInvoice.driverInvoiceCode,
|
||||
object : OnResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("--成功--", "申请发票成功")
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("--失败--", "申请发票失败$s$s1")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,10 +6,8 @@ import android.os.Bundle
|
||||
import android.os.Process
|
||||
import cn.jiguang.api.utils.JCollectionAuth
|
||||
import cn.jpush.android.api.JPushInterface
|
||||
import com.alct.mdp.MDPLocationCollectionManager
|
||||
import com.amap.api.location.AMapLocationClient
|
||||
import com.amap.api.maps.MapsInitializer
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.databinding.ActivityLauncherBinding
|
||||
import com.arpa.hndahesudintocctmsdriver.third.JTTProcess
|
||||
import com.arpa.hndahesudintocctmsdriver.third.SPUtil
|
||||
@ -82,10 +80,7 @@ class LauncherActivity : BaseActivity<ActivityLauncherBinding>() {
|
||||
//安联初始化
|
||||
if (packageName == getCurrentProcessName(this)) {
|
||||
//Log.e("--使用的测试环境--",BuildConfig.OPEN_API_URL);
|
||||
MDPLocationCollectionManager.initialize(
|
||||
applicationContext,
|
||||
BuildConfig.OPEN_AL_URL
|
||||
)
|
||||
|
||||
}
|
||||
//初始化交通厅
|
||||
JTTProcess.init(application)
|
||||
|
@ -20,7 +20,6 @@ import com.arpa.hndahesudintocctmsdriver.event.GoWaybillEvent
|
||||
import com.arpa.hndahesudintocctmsdriver.net.BaseObserver
|
||||
import com.arpa.hndahesudintocctmsdriver.net.DataManager
|
||||
import com.arpa.hndahesudintocctmsdriver.net.RxHttpCallBack
|
||||
import com.arpa.hndahesudintocctmsdriver.third.ALProcess
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.home.activity.BusinessActivity
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.mine.activity.PersonInfoActivity
|
||||
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillDetailActivity
|
||||
@ -207,7 +206,8 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(), RefreshCallBack {
|
||||
|
||||
|
||||
// getLocation()
|
||||
ALProcess.verification(mContext)
|
||||
//安联认证
|
||||
// ALProcess.verification(mContext)
|
||||
//证件过期判断+轨迹上传判断
|
||||
DataManager.getInstance().getUserInfo()
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
@ -220,7 +220,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(), RefreshCallBack {
|
||||
|
||||
//初始化安联
|
||||
if (t.data.auditStatus == "100003") {
|
||||
ALProcess.verification(mContext)
|
||||
|
||||
}
|
||||
|
||||
//执行中运单轨迹上传
|
||||
|
@ -3,19 +3,17 @@ package com.arpa.hndahesudintocctmsdriver.ui.waybill.activity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.alct.mdp.MDPLocationCollectionManager
|
||||
import com.alct.mdp.callback.OnResultListener
|
||||
import com.alct.mdp.model.Goods
|
||||
import com.alct.mdp.model.Image
|
||||
import com.alct.mdp.model.Location
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.arpa.hndahesudintocctmsdriver.base.AppConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.GDImage
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.GDLocation
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.LUInputBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.OrderDetailBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpPicBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.WaybillPhoto
|
||||
import com.arpa.hndahesudintocctmsdriver.callback.OnGDDownloadResultListener
|
||||
import com.arpa.hndahesudintocctmsdriver.callback.OnGDResultListener
|
||||
import com.arpa.hndahesudintocctmsdriver.databinding.ActivityWaybillUppicBinding
|
||||
import com.arpa.hndahesudintocctmsdriver.net.BaseObserver
|
||||
import com.arpa.hndahesudintocctmsdriver.net.DataManager
|
||||
@ -23,6 +21,7 @@ import com.arpa.hndahesudintocctmsdriver.net.RxHttpCallBack
|
||||
import com.arpa.hndahesudintocctmsdriver.oss.OssServiceUtil
|
||||
import com.arpa.hndahesudintocctmsdriver.third.JTTProcess
|
||||
import com.arpa.hndahesudintocctmsdriver.utils.GDLocationUtils
|
||||
import com.arpa.hndahesudintocctmsdriver.utils.NewLJUtils
|
||||
import com.arpa.hndahesudintocctmsdriver.utils.OcrUtils
|
||||
import com.arpa.hndahesudintocctmsdriver.utils.OrderUtils
|
||||
import com.arpa.mylibrary.adapter.GridImageAdapter
|
||||
@ -125,14 +124,15 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
)
|
||||
|
||||
var myAdapter = GridImageAdapter(mContext, mData)
|
||||
myAdapter.selectMax = if (type==2) 6 else 1
|
||||
myAdapter.selectMax = if (type == 2) 6 else 1
|
||||
myAdapter.setOnItemClickListener(object : OnItemClickListener {
|
||||
override fun onItemClick(v: View?, position: Int) {
|
||||
PopsUtils.getInstance()
|
||||
.showSelPic(mContext, if (type==2) 6 else 1, true, myAdapter) { it ->
|
||||
OssServiceUtil.getInstance().asyncPutImages(it.map { it.availablePath },this@WaybillUpPicActivity
|
||||
.showSelPic(mContext, if (type == 2) 6 else 1, true, myAdapter) { it ->
|
||||
OssServiceUtil.getInstance().asyncPutImages(
|
||||
it.map { it.availablePath }, this@WaybillUpPicActivity
|
||||
) { success, failure ->
|
||||
upBean.waybillPhotoList.removeAll { it.type=="3" }
|
||||
upBean.waybillPhotoList.removeAll { it.type == "3" }
|
||||
success.forEachIndexed { index, s ->
|
||||
picBean = WaybillPhoto()
|
||||
picBean.run {
|
||||
@ -157,10 +157,11 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
|
||||
override fun openPicture() {
|
||||
PopsUtils.getInstance()
|
||||
.showSelPic(mContext, if (type==2) 6 else 1, true, myAdapter) { it ->
|
||||
OssServiceUtil.getInstance().asyncPutImages(it.map { it.availablePath },this@WaybillUpPicActivity
|
||||
.showSelPic(mContext, if (type == 2) 6 else 1, true, myAdapter) { it ->
|
||||
OssServiceUtil.getInstance().asyncPutImages(
|
||||
it.map { it.availablePath }, this@WaybillUpPicActivity
|
||||
) { success, failure ->
|
||||
upBean.waybillPhotoList.removeAll { it.type=="3" }
|
||||
upBean.waybillPhotoList.removeAll { it.type == "3" }
|
||||
success.forEachIndexed { index, s ->
|
||||
picBean = WaybillPhoto()
|
||||
picBean.run {
|
||||
@ -263,7 +264,7 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
return
|
||||
}
|
||||
|
||||
var dis =
|
||||
val dis =
|
||||
TimeUtil.compareNowDate(TimeUtil.string2Millis(orderBean.waybillInfo.loadTime))
|
||||
if (dis <= 5) { //大于五分钟可以接单
|
||||
ToastUtils.showToast(this@WaybillUpPicActivity, "请到卸货地再进行卸货操作!")
|
||||
@ -271,86 +272,124 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
val l = Location()
|
||||
l.baiduLongitude = bdLatLng.longitude
|
||||
l.baiduLatitude = bdLatLng.latitude
|
||||
l.location = binding.tvLoca.text.toString()
|
||||
l.time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
val l = GDLocation().apply {
|
||||
baiduLongitude = bdLatLng.longitude
|
||||
baiduLatitude = bdLatLng.latitude
|
||||
location = binding.tvLoca.text.toString()
|
||||
time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
}
|
||||
|
||||
if (orderType == 1) {//装货
|
||||
load(l)
|
||||
} else {//卸货
|
||||
unLoad(l)
|
||||
}
|
||||
|
||||
|
||||
// DataManager.getInstance().driverLoadOrUnload(upBean)
|
||||
// .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||
// override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
// super.onSuccess(t)
|
||||
// if (1 == orderType) {
|
||||
// ActivityUtils.startActivity(
|
||||
// mContext,
|
||||
// WaybillSuccActivity::class.java,
|
||||
// intent.extras
|
||||
// )
|
||||
// //装货成功-开启轨迹上传
|
||||
// OrderUtils.getInstance().upLocation(mContext)
|
||||
// } else {
|
||||
// OrderUtils.getInstance().stopUpLocation(mContext)
|
||||
// ActivityUtils.startActivity(
|
||||
// mContext,
|
||||
// WaybillSuccActivity::class.java,
|
||||
// intent.extras
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }))
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun load(location: Location) {
|
||||
MDPLocationCollectionManager.pickup(
|
||||
mContext,
|
||||
orderBean.orderNum,
|
||||
location,
|
||||
object : OnResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "装货上传成功")
|
||||
private fun load(location: GDLocation) {
|
||||
NewLJUtils.getInstance()
|
||||
.getShipmentStatus(mContext, orderBean.orderNum, object : OnGDDownloadResultListener {
|
||||
override fun onSuccess(var1: String) {
|
||||
if (var1 == "30") {
|
||||
Log.e("上报安联", "装货上传成功")
|
||||
// //上传安联和交通厅,平台-装货
|
||||
// //交通厅
|
||||
if (orderBean.report === "1") {
|
||||
JTTProcess.start(mContext, orderBean, "")
|
||||
}
|
||||
|
||||
//上传安联和交通厅,平台-装货
|
||||
//交通厅
|
||||
if (orderBean.report === "1") {
|
||||
JTTProcess.start(mContext, orderBean, "")
|
||||
upLoadImage()
|
||||
|
||||
DataManager.getInstance().driverLoadOrUnload(upBean)
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
//装货成功-开启轨迹上传
|
||||
OrderUtils.getInstance().upLocation(mContext)
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
NewLJUtils.getInstance()
|
||||
.pickUp(mContext, orderBean.orderNum, location, object :
|
||||
OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "装货上传成功")
|
||||
|
||||
//上传安联和交通厅,平台-装货
|
||||
//交通厅
|
||||
if (orderBean.report === "1") {
|
||||
JTTProcess.start(mContext, orderBean, "")
|
||||
}
|
||||
upLoadImage()
|
||||
DataManager.getInstance().driverLoadOrUnload(upBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
BaseObserver(
|
||||
mContext,
|
||||
object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
//装货成功-开启轨迹上传
|
||||
OrderUtils.getInstance()
|
||||
.upLocation(mContext)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFailure(code: String, message: String) {
|
||||
ToastUtils.showToast(mContext, """${code},${message}""")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
upLoadImage()
|
||||
|
||||
DataManager.getInstance().driverLoadOrUnload(upBean)
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
//装货成功-开启轨迹上传
|
||||
OrderUtils.getInstance().upLocation(mContext)
|
||||
}
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
override fun onFailure(p0: String?, p1: String?) {
|
||||
Log.e("上报安联失败(装货):", p0 + p1)
|
||||
ToastUtils.showToast(mContext, """${p1},${p0}""")
|
||||
override fun onFailure(code: String, message: String) {
|
||||
ToastUtils.showToast(mContext, """${code},${message}""")
|
||||
}
|
||||
})
|
||||
|
||||
// MDPLocationCollectionManager.pickup(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// location,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "装货上传成功")
|
||||
//
|
||||
// //上传安联和交通厅,平台-装货
|
||||
// //交通厅
|
||||
// if (orderBean.report === "1") {
|
||||
// JTTProcess.start(mContext, orderBean, "")
|
||||
// }
|
||||
//
|
||||
// upLoadImage()
|
||||
//
|
||||
// DataManager.getInstance().driverLoadOrUnload(upBean)
|
||||
// .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||
// override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
// super.onSuccess(t)
|
||||
// //装货成功-开启轨迹上传
|
||||
// OrderUtils.getInstance().upLocation(mContext)
|
||||
// }
|
||||
// }))
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(p0: String?, p1: String?) {
|
||||
// Log.e("上报安联失败(装货):", p0 + p1)
|
||||
// ToastUtils.showToast(mContext, """${p1},${p0}""")
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
private fun unLoad(location: Location) {
|
||||
private fun unLoad(location: GDLocation) {
|
||||
showLoading()
|
||||
MDPLocationCollectionManager.unload(mContext, orderBean.orderNum, location,
|
||||
object : OnResultListener {
|
||||
NewLJUtils.getInstance()
|
||||
.unload(mContext, orderBean.orderNum, location, object : OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "卸货上传成功")
|
||||
// 交通厅
|
||||
@ -376,14 +415,47 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
|
||||
}
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("上报安联失败(卸货):", s + s1)
|
||||
// MessageUtils().showCenMessage(con, s1)
|
||||
override fun onFailure(code: String, message: String) {
|
||||
Log.e("上报安联失败(卸货):", code + message)
|
||||
}
|
||||
})
|
||||
// MDPLocationCollectionManager.unload(mContext, orderBean.orderNum, location,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "卸货上传成功")
|
||||
// // 交通厅
|
||||
// if (orderBean.report === "1") {
|
||||
// JTTProcess.stop(mContext, orderBean, "")
|
||||
// }
|
||||
// //卸货状态-平台
|
||||
//// hyr.dischargeCargo(lub)
|
||||
// //卸货照片-安联
|
||||
// upUnloadImage()
|
||||
//
|
||||
// //卸货回单
|
||||
// upTrafficSign(location)
|
||||
// upTrafficReceipt(location)
|
||||
// receiptImage()
|
||||
//
|
||||
// //todo 平台更换运单状态 暂时注释
|
||||
// DataManager.getInstance().driverLoadOrUnload(upBean)
|
||||
// .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
|
||||
// override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
// super.onSuccess(t)
|
||||
//
|
||||
// }
|
||||
// }))
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// Log.e("上报安联失败(卸货):", s + s1)
|
||||
//// MessageUtils().showCenMessage(con, s1)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
@ -392,24 +464,24 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
///storage/emulated/0/Android/data/com.oneclouds.wangluohuoyun/files/Pictures/163124593063154.jpg
|
||||
|
||||
var photoPaht = upBean.waybillPhotoList.find { it.type == "1" }?.localPhotoUrl
|
||||
val file = File(photoPaht)
|
||||
val image = Image()
|
||||
val base: String = BitmapUtil.imageToBase64(photoPaht)
|
||||
image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
image.fileExt = FileUtil.lastName(file)
|
||||
image.fileName = FileUtil.fileName(file)
|
||||
image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
image.baiduLongitude = bdLatLng.longitude
|
||||
image.baiduLatitude = bdLatLng.latitude
|
||||
image.location = binding.tvLoca.text.toString()
|
||||
MDPLocationCollectionManager.uploadPickupImage(
|
||||
mContext,
|
||||
orderBean.orderNum,
|
||||
image,
|
||||
object : OnResultListener {
|
||||
val file = File(photoPaht)
|
||||
val image = GDImage().apply {
|
||||
fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
fileExt = FileUtil.lastName(file)
|
||||
fileName = FileUtil.fileName(file)
|
||||
imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
baiduLongitude = bdLatLng.longitude
|
||||
baiduLatitude = bdLatLng.latitude
|
||||
location = binding.tvLoca.text.toString()
|
||||
}
|
||||
|
||||
NewLJUtils.getInstance()
|
||||
.uploadPickupImage(mContext, orderBean.orderNum, image, object : OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "装货照片上传成功")
|
||||
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
ToastUtils.showToast(mContext, "上传成功")
|
||||
ActivityUtils.startActivity(
|
||||
mContext,
|
||||
WaybillSuccActivity::class.java,
|
||||
@ -417,98 +489,136 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("上报安联失败(装货照片):", s + s1)
|
||||
override fun onFailure(code: String, message: String) {
|
||||
Log.e("上报安联失败(装货照片):", code + message)
|
||||
}
|
||||
})
|
||||
|
||||
// MDPLocationCollectionManager.uploadPickupImage(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// image,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "装货照片上传成功")
|
||||
// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
// ActivityUtils.startActivity(
|
||||
// mContext,
|
||||
// WaybillSuccActivity::class.java,
|
||||
// intent.extras
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// Log.e("上报安联失败(装货照片):", s + s1)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
//上传安联卸货
|
||||
fun upUnloadImage() {
|
||||
var photoPaht = upBean.waybillPhotoList.find { it.type == "2" }?.localPhotoUrl
|
||||
val file = File(photoPaht)
|
||||
val image = Image()
|
||||
val base = BitmapUtil.imageToBase64(photoPaht)
|
||||
image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
image.fileExt = FileUtil.lastName(file)
|
||||
image.fileName = FileUtil.fileName(file)
|
||||
image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
image.baiduLongitude = bdLatLng.longitude
|
||||
image.baiduLatitude = bdLatLng.latitude
|
||||
image.location = binding.tvLoca.text.toString()
|
||||
MDPLocationCollectionManager.uploadUnloadImage(
|
||||
mContext,
|
||||
orderBean.orderNum,
|
||||
image,
|
||||
object : OnResultListener {
|
||||
val image = GDImage().apply {
|
||||
fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
fileExt = FileUtil.lastName(file)
|
||||
fileName = FileUtil.fileName(file)
|
||||
imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
baiduLongitude = bdLatLng.longitude
|
||||
baiduLatitude = bdLatLng.latitude
|
||||
location = binding.tvLoca.text.toString()
|
||||
time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
}
|
||||
|
||||
NewLJUtils.getInstance()
|
||||
.uploadUnloadImage(mContext, orderBean.orderNum, image, object : OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "卸货照片上传成功")
|
||||
// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
// finish()
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("上报安联失败(卸货照片):", s + s1)
|
||||
// SPUtil.insSP(con,"make","卸货",sob.getData().getShippingNoteNumber());
|
||||
// SPUtil.insSP(con,"make","卸货-"+sob.getData().getShippingNoteNumber(),gson.toJson(image));
|
||||
// Intent serviceIn=new Intent(con, MakeUpAlService.class);
|
||||
// startService(serviceIn);
|
||||
override fun onFailure(code: String, message: String) {
|
||||
Log.e("上报安联失败(卸货照片):", code + message)
|
||||
}
|
||||
})
|
||||
|
||||
// MDPLocationCollectionManager.uploadUnloadImage(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// image,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "卸货照片上传成功")
|
||||
//// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
//// finish()
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// Log.e("上报安联失败(卸货照片):", s + s1)
|
||||
// // SPUtil.insSP(con,"make","卸货",sob.getData().getShippingNoteNumber());
|
||||
//// SPUtil.insSP(con,"make","卸货-"+sob.getData().getShippingNoteNumber(),gson.toJson(image));
|
||||
//// Intent serviceIn=new Intent(con, MakeUpAlService.class);
|
||||
//// startService(serviceIn);
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
//上传安联-签收
|
||||
fun upTrafficSign(location: Location) {
|
||||
fun upTrafficSign(location: GDLocation) {
|
||||
//安联
|
||||
val gs = mutableListOf<Goods>()
|
||||
orderBean.goodsList.forEach {
|
||||
var g = Goods()
|
||||
g.goodsName = it.goodName
|
||||
g.unit = it.packName
|
||||
g.itemNo = it.orderGoodsId.toInt()
|
||||
//实收
|
||||
g.quantity = 1
|
||||
//应收
|
||||
g.receivedQuantity = 1
|
||||
//破损
|
||||
g.damageQuantity = 1
|
||||
//丢失
|
||||
g.quantity = 1
|
||||
gs.add(g)
|
||||
}
|
||||
MDPLocationCollectionManager.sign(
|
||||
mContext,
|
||||
orderBean.orderNum,
|
||||
location,
|
||||
gs,
|
||||
object : OnResultListener {
|
||||
NewLJUtils.getInstance()
|
||||
.sign(mContext, orderBean.orderNum, location, object : OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "签收成功")
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("上报安联失败(签收):", s + s1)
|
||||
override fun onFailure(code: String, message: String) {
|
||||
Log.e("上报安联失败(签收):", code + message)
|
||||
}
|
||||
})
|
||||
// MDPLocationCollectionManager.sign(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// location,
|
||||
// gs,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "签收成功")
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// Log.e("上报安联失败(签收):", s + s1)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
//上传安联-回单
|
||||
fun upTrafficReceipt(location: Location) {
|
||||
fun upTrafficReceipt(location: GDLocation) {
|
||||
//安联
|
||||
MDPLocationCollectionManager.pod(
|
||||
mContext,
|
||||
orderBean.orderNum,
|
||||
location,
|
||||
object : OnResultListener {
|
||||
NewLJUtils.getInstance()
|
||||
.pod(mContext, orderBean.orderNum, location, object : OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "回单上传成功")
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
Log.e("上报安联失败(回单):", s + s1)
|
||||
override fun onFailure(code: String, message: String) {
|
||||
Log.e("上报安联失败(回单):", code + message)
|
||||
}
|
||||
})
|
||||
// MDPLocationCollectionManager.pod(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// location,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "回单上传成功")
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// Log.e("上报安联失败(回单):", s + s1)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
//卸货回单照片
|
||||
@ -518,25 +628,25 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.forEach { it ->
|
||||
var photoPaht = it.localPhotoUrl
|
||||
val file: File = File(photoPaht)
|
||||
val image = Image()
|
||||
val base = BitmapUtil.imageToBase64(photoPaht)
|
||||
image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
image.fileExt = FileUtil.lastName(file)
|
||||
image.fileName = FileUtil.fileName(file)
|
||||
image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
image.baiduLongitude = bdLatLng.longitude
|
||||
image.baiduLatitude = bdLatLng.latitude
|
||||
image.location = binding.tvLoca.text.toString()
|
||||
MDPLocationCollectionManager.uploadPODImage(
|
||||
mContext,
|
||||
orderBean.orderNum,
|
||||
image,
|
||||
object : OnResultListener {
|
||||
val image = GDImage().apply {
|
||||
fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
fileExt = FileUtil.lastName(file)
|
||||
fileName = FileUtil.fileName(file)
|
||||
imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
baiduLongitude = bdLatLng.longitude
|
||||
baiduLatitude = bdLatLng.latitude
|
||||
location = binding.tvLoca.text.toString()
|
||||
}
|
||||
|
||||
NewLJUtils.getInstance()
|
||||
.uploadPODImage(mContext, orderBean.orderNum, image, object : OnGDResultListener {
|
||||
override fun onSuccess() {
|
||||
Log.e("上报安联", "回单照片上传成功")
|
||||
upCount++
|
||||
dissLoading()
|
||||
if (upCount==upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size){
|
||||
if (upCount == upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size) {
|
||||
//跳转成功页面,停止上传轨迹
|
||||
OrderUtils.getInstance().stopUpLocation(mContext)
|
||||
ActivityUtils.startActivity(
|
||||
@ -544,15 +654,13 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
WaybillSuccActivity::class.java,
|
||||
intent.extras
|
||||
)
|
||||
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
ToastUtils.showToast(mContext, "上传成功")
|
||||
}
|
||||
|
||||
// finish()
|
||||
}
|
||||
|
||||
override fun onFailure(s: String, s1: String) {
|
||||
override fun onFailure(code: String, message: String) {
|
||||
upCount++
|
||||
if (upCount==upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size){
|
||||
if (upCount == upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size) {
|
||||
//跳转成功页面,停止上传轨迹
|
||||
OrderUtils.getInstance().stopUpLocation(mContext)
|
||||
ActivityUtils.startActivity(
|
||||
@ -560,60 +668,54 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
|
||||
WaybillSuccActivity::class.java,
|
||||
intent.extras
|
||||
)
|
||||
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
ToastUtils.showToast(mContext, "上传成功")
|
||||
}
|
||||
Log.e("上报安联失败(回单照片):", s + s1)
|
||||
// SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber());
|
||||
//// SPUtil.insSP(con,"make","回单-"+sob.getData().getShippingNoteNumber(),gson.toJson(image));
|
||||
//// Intent serviceIn=new Intent(con, MakeUpAlService.class);
|
||||
//// startService(serviceIn);
|
||||
Log.e("上报安联失败(回单照片):", code + message)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// var photoPaht =
|
||||
// upBean.waybillPhotoList.find { it.type == "3" && it.receiptType == "5" }?.localPhotoUrl
|
||||
// val file: File = File(photoPaht)
|
||||
// val image = Image()
|
||||
// val base = BitmapUtil.imageToBase64(photoPaht)
|
||||
// image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
|
||||
// image.fileExt = FileUtil.lastName(file)
|
||||
// image.fileName = FileUtil.fileName(file)
|
||||
// image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
|
||||
// image.baiduLongitude = bdLatLng.longitude
|
||||
// image.baiduLatitude = bdLatLng.latitude
|
||||
// image.location = binding.tvLoca.text.toString()
|
||||
// MDPLocationCollectionManager.uploadPODImage(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// image,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "回单照片上传成功")
|
||||
// dissLoading()
|
||||
// //跳转成功页面,停止上传轨迹
|
||||
// OrderUtils.getInstance().stopUpLocation(mContext)
|
||||
// ActivityUtils.startActivity(
|
||||
// mContext,
|
||||
// WaybillSuccActivity::class.java,
|
||||
// intent.extras
|
||||
// )
|
||||
// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
//// finish()
|
||||
// }
|
||||
// MDPLocationCollectionManager.uploadPODImage(
|
||||
// mContext,
|
||||
// orderBean.orderNum,
|
||||
// image,
|
||||
// object : OnResultListener {
|
||||
// override fun onSuccess() {
|
||||
// Log.e("上报安联", "回单照片上传成功")
|
||||
// upCount++
|
||||
// dissLoading()
|
||||
// if (upCount==upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size){
|
||||
// //跳转成功页面,停止上传轨迹
|
||||
// OrderUtils.getInstance().stopUpLocation(mContext)
|
||||
// ActivityUtils.startActivity(
|
||||
// mContext,
|
||||
// WaybillSuccActivity::class.java,
|
||||
// intent.extras
|
||||
// )
|
||||
// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// Log.e("上报安联失败(回单照片):", s + s1)
|
||||
// // SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber());
|
||||
//// finish()
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(s: String, s1: String) {
|
||||
// upCount++
|
||||
// if (upCount==upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size){
|
||||
// //跳转成功页面,停止上传轨迹
|
||||
// OrderUtils.getInstance().stopUpLocation(mContext)
|
||||
// ActivityUtils.startActivity(
|
||||
// mContext,
|
||||
// WaybillSuccActivity::class.java,
|
||||
// intent.extras
|
||||
// )
|
||||
// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
|
||||
// }
|
||||
// Log.e("上报安联失败(回单照片):", s + s1)
|
||||
// // SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber());
|
||||
////// SPUtil.insSP(con,"make","回单-"+sob.getData().getShippingNoteNumber(),gson.toJson(image));
|
||||
////// Intent serviceIn=new Intent(con, MakeUpAlService.class);
|
||||
////// startService(serviceIn);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,599 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.arpa.hndahesudintocctmsdriver.BuildConfig
|
||||
import com.arpa.hndahesudintocctmsdriver.base.NewLJConstant
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.GDImage
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.GDLocation
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.InvoiceBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.LjTokenBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.PickupBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.ShipmentStatusBean
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UpimgBean
|
||||
import com.arpa.hndahesudintocctmsdriver.callback.OnGDDownloadResultListener
|
||||
import com.arpa.hndahesudintocctmsdriver.callback.OnGDResultListener
|
||||
import com.arpa.hndahesudintocctmsdriver.net.BaseObserver
|
||||
import com.arpa.hndahesudintocctmsdriver.net.DataManager
|
||||
import com.arpa.hndahesudintocctmsdriver.net.RxHttpCallBack
|
||||
import com.arpa.mylibrary.base.SingletonNoPHolder
|
||||
import com.arpa.mylibrary.bean.LJDriverBean
|
||||
import com.arpa.mylibrary.net.CommonResponseBean
|
||||
import com.arpa.mylibrary.utils.BaseSPUtils
|
||||
import com.arpa.mylibrary.utils.BaseSPUtils.NEW_LJ_TOKEN
|
||||
import com.arpa.mylibrary.utils.ToastUtils
|
||||
import com.express.mdp.Api
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* @ClassName NewLJUtils
|
||||
* @Author john
|
||||
* @Date 2025/1/21 08:59
|
||||
* @Description TODO
|
||||
*/
|
||||
class NewLJUtils private constructor() {
|
||||
|
||||
companion object : SingletonNoPHolder<NewLJUtils>(::NewLJUtils)
|
||||
|
||||
fun getToken(ctx: Context) {
|
||||
val ljTokenBean = LjTokenBean().apply {
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
enterpriseIdentity = NewLJConstant.ENTER_PRISE_IDENTITY
|
||||
enterpriseKey = NewLJConstant.ENTER_PRISE_KEY
|
||||
}
|
||||
|
||||
DataManager.getInstance().getToken(ljTokenBean)
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
BaseSPUtils.put(ctx, NEW_LJ_TOKEN, t.getToken())
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
fun getToken(ctx: Context?, listener: OnGDResultListener) {
|
||||
val ljTokenBean = LjTokenBean().apply {
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
enterpriseIdentity = NewLJConstant.ENTER_PRISE_IDENTITY
|
||||
enterpriseKey = NewLJConstant.ENTER_PRISE_KEY
|
||||
}
|
||||
|
||||
DataManager.getInstance().getToken(ljTokenBean)
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx!!, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
BaseSPUtils.put(ctx, NEW_LJ_TOKEN, t.getToken())
|
||||
if (listener != null) listener.onSuccess()
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运单提货
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param location
|
||||
*/
|
||||
fun pickUp(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
location: GDLocation,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (location.baiduLongitude == 0.0 || location.baiduLatitude == 0.0) {
|
||||
ToastUtils.showToast(ctx, "经纬度不能为空")
|
||||
return
|
||||
}
|
||||
val pickupBean = PickupBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
this.location = location
|
||||
}
|
||||
DataManager.getInstance().pickup(pickupBean)
|
||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单提货操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运单卸货
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param location
|
||||
*/
|
||||
fun unload(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
location: GDLocation,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (location.baiduLongitude == 0.0 || location.baiduLatitude == 0.0) {
|
||||
ToastUtils.showToast(ctx, "经纬度不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
val pickupBean = PickupBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
this.location = location
|
||||
}
|
||||
DataManager.getInstance().unload(pickupBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单卸货操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单签收
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param location
|
||||
*/
|
||||
fun sign(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
location: GDLocation,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (location.baiduLongitude == 0.0 || location.baiduLatitude == 0.0) {
|
||||
ToastUtils.showToast(ctx, "经纬度不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
val pickupBean = PickupBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
this.location = location
|
||||
}
|
||||
DataManager.getInstance().sign(pickupBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单签收操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单回单
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param location
|
||||
*/
|
||||
fun pod(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
location: GDLocation,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (location.baiduLongitude == 0.0 || location.baiduLatitude == 0.0) {
|
||||
ToastUtils.showToast(ctx, "经纬度不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
val pickupBean = PickupBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
this.location = location
|
||||
}
|
||||
|
||||
DataManager.getInstance().pod(pickupBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单回单操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运单提货照片上传
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param imageDTO
|
||||
*/
|
||||
fun uploadPickupImage(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
imageDTO: GDImage,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(imageDTO.fileName)) {
|
||||
ToastUtils.showToast(ctx, "照片不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
val pickupBean: UpimgBean = UpimgBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
image = imageDTO
|
||||
}
|
||||
DataManager.getInstance().uploadPickupImage(pickupBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单提货照片操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运单卸货照片上传
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param imageDTO
|
||||
*/
|
||||
fun uploadUnloadImage(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
imageDTO: GDImage,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(imageDTO.fileName)) {
|
||||
ToastUtils.showToast(ctx, "照片不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
val pickupBean: UpimgBean = UpimgBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
image = imageDTO
|
||||
}
|
||||
|
||||
DataManager.getInstance().uploadUnloadImage(pickupBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单卸货照片操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运单回单照片上传
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
* @param imageDTO
|
||||
*/
|
||||
fun uploadPODImage(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
imageDTO: GDImage,
|
||||
listener: OnGDResultListener
|
||||
) {
|
||||
if (TextUtils.isEmpty(shipmentCode)) {
|
||||
ToastUtils.showToast(ctx, "运单号不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(imageDTO.fileName)) {
|
||||
ToastUtils.showToast(ctx, "照片不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
val pickupBean: UpimgBean = UpimgBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
image = imageDTO
|
||||
}
|
||||
DataManager.getInstance().uploadPODImage(pickupBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单回单照片操作异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意发票申请
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
fun confirmInvoice(ctx: Context, listener: OnGDResultListener) {
|
||||
val userInfo = SPUtils.instance.getUserInfo(ctx)
|
||||
if (userInfo == null){
|
||||
ToastUtils.showToast(ctx, "账号未登录")
|
||||
return
|
||||
}
|
||||
if (TextUtils.isEmpty(userInfo.idcard)){
|
||||
ToastUtils.showToast(ctx, "未查到身份证号码")
|
||||
return
|
||||
}
|
||||
val idcard = userInfo.idcard
|
||||
|
||||
searchDriver(ctx, idcard, object : OnGDDownloadResultListener {
|
||||
override fun onSuccess(var1: String) {
|
||||
val invoiceBean: InvoiceBean = InvoiceBean().apply {
|
||||
enterpriseCode=NewLJConstant.ENTER_PRISE_CODE
|
||||
driverInvoiceCode = var1
|
||||
driverIdentification = idcard
|
||||
}
|
||||
DataManager.getInstance().confirmInvoice(invoiceBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "同意发票异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
override fun onFailure(code: String, message: String) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运单状态查询
|
||||
*
|
||||
* @param ctx
|
||||
* @param shipmentCode
|
||||
*/
|
||||
fun getShipmentStatus(
|
||||
ctx: Context,
|
||||
shipmentCode: String,
|
||||
listener: OnGDDownloadResultListener
|
||||
) {
|
||||
val shipmentStatusBean: ShipmentStatusBean = ShipmentStatusBean().apply {
|
||||
this.shipmentCode = shipmentCode
|
||||
enterpriseCode = NewLJConstant.ENTER_PRISE_CODE
|
||||
}
|
||||
DataManager.getInstance().getShipmentStatus(shipmentStatusBean)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
listener.onSuccess(t.statusCode)
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "运单状态查询异常" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启位置上传
|
||||
*
|
||||
* @param act
|
||||
*/
|
||||
fun startLocationService(act: AppCompatActivity) {
|
||||
val userInfo = SPUtils.instance.getUserInfo(act)
|
||||
if (userInfo == null){
|
||||
ToastUtils.showToast(act, "账号未登录")
|
||||
return
|
||||
}
|
||||
if (TextUtils.isEmpty(userInfo.idcard)){
|
||||
ToastUtils.showToast(act, "未查到身份证号码")
|
||||
return
|
||||
}
|
||||
val idcard = userInfo.idcard
|
||||
searchDriver(act, idcard, object : OnGDDownloadResultListener {
|
||||
override fun onSuccess(var1: String) {
|
||||
try {
|
||||
//开启定位服务
|
||||
if (BuildConfig.isTest) {
|
||||
Api.setBaseUrl("https://kehui56.cn/api", "https://api.kehui56.cn/api")
|
||||
}
|
||||
val result = Api.startLocationService(
|
||||
act, var1
|
||||
) { s: String? ->
|
||||
Log.e(
|
||||
"位置上报",
|
||||
s!!
|
||||
)
|
||||
}
|
||||
println(result)
|
||||
} catch (e: Exception) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(code: String, message: String) {
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭定位服务
|
||||
*/
|
||||
fun stopLocationService() {
|
||||
Api.stopLocationService()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询司机
|
||||
*/
|
||||
fun searchDriver(ctx: Context, idCard: String, listener: OnGDDownloadResultListener) {
|
||||
DataManager.getInstance().searchDriver(idCard)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(BaseObserver(ctx, object : RxHttpCallBack<Any>() {
|
||||
override fun onSuccess(t: CommonResponseBean<Any>) {
|
||||
super.onSuccess(t)
|
||||
val driver: LJDriverBean = t.driver
|
||||
if (!TextUtils.isEmpty(driver.driverCode)) {
|
||||
listener.onSuccess(driver.driverCode)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCodeError(
|
||||
mContext: Context?,
|
||||
t: CommonResponseBean<Any>
|
||||
) {
|
||||
super.onCodeError(mContext, t)
|
||||
listener.onFailure(
|
||||
t.code.toString(),
|
||||
if (TextUtils.isEmpty(t.message)) "司机异常请联系管理员" else t.message
|
||||
)
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.arpa.mylibrary.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName LJDriverBean
|
||||
* @Author john
|
||||
* @Date 2025/1/21 10:47
|
||||
* @Description TODO
|
||||
*/
|
||||
public class LJDriverBean 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.arpa.mylibrary.net;
|
||||
|
||||
import com.arpa.mylibrary.bean.LJDriverBean;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -18,6 +20,70 @@ public class CommonResponseBean<T> extends JSONObject implements Serializable {
|
||||
|
||||
private boolean success;
|
||||
|
||||
private String message;
|
||||
private String url;
|
||||
private String fileName;
|
||||
private String token;
|
||||
private String expiryIn;
|
||||
private String statusCode;
|
||||
|
||||
private LJDriverBean driver;
|
||||
|
||||
public LJDriverBean getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(LJDriverBean driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getExpiryIn() {
|
||||
return expiryIn;
|
||||
}
|
||||
|
||||
public void setExpiryIn(String expiryIn) {
|
||||
this.expiryIn = expiryIn;
|
||||
}
|
||||
|
||||
public String getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(String statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public int getRes() {
|
||||
return res;
|
||||
|
@ -1,68 +0,0 @@
|
||||
package com.arpa.mylibrary.net;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
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 {
|
||||
JSONObject jsonObject = new JSONObject(responseBodyStr);
|
||||
String str = jsonObject.optString("data");
|
||||
int code = jsonObject.optInt("code");
|
||||
// if (500 == code) {
|
||||
// jsonObject.put("data", new JSONObject());
|
||||
// throw new ResultException();
|
||||
// } else {
|
||||
// if (TextUtils.isEmpty(str)) {
|
||||
// jsonObject.put("data", new JSONObject());
|
||||
// }
|
||||
// }
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ public class BaseSPUtils {
|
||||
public static final String USER_INFO_KEY = "driver_user_info_key";
|
||||
public static final String USER_TOKEN_KEY = "driver_user_token_key";
|
||||
public static final String NET_SERVICE_TEST = "driver_net_service_test";
|
||||
public static final String NEW_LJ_TOKEN = "NEW_LJ_TOKEN";
|
||||
public static final String SEARRH_CACHE = "driver_search_cache";
|
||||
public static final String NAVI_PH_EDIT_CACHE = "driver_navi_ph_edit_cache";
|
||||
public static final String FIRST_OPEN = "driver_first_open";
|
||||
|
Loading…
Reference in New Issue
Block a user