113 lines
4.3 KiB
Java
113 lines
4.3 KiB
Java
package com.arpa.hndahesudintocctmsdriver.util;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.os.Handler;
|
|
import android.os.Message;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.widget.Toast;
|
|
|
|
import com.arpa.hndahesudintocctmsdriver.bean.JTT;
|
|
import com.arpa.hndahesudintocctmsdriver.bean.StartOrderBean;
|
|
import com.arpa.hndahesudintocctmsdriver.constant.JTTConstant;
|
|
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
|
import com.arpa.hndahesudintocctmsdriver.report.JTTProcess;
|
|
import com.arpa.hndahesudintocctmsdriver.request.HuoYuanRequset;
|
|
import com.arpa.hndahesudintocctmsdriver.request.UserRequset;
|
|
import com.arpa.hndahesudintocctmsdriver.service.TrackService;
|
|
import com.arpa.hndahesudintocctmsdriver.ui.home.HuoYuanFragmengt;
|
|
import com.arpa.hndahesudintocctmsdriver.util.cache.CacheGroup;
|
|
import com.arpa.hndahesudintocctmsdriver.util.http.RequsetCodeConstants;
|
|
import com.arpa.hndahesudintocctmsdriver.util.sp.SPUtil;
|
|
import com.arpa.hndahesudintocctmsdriver.util.string.StringUtil;
|
|
import com.dahe.mylibrary.utils.SelectPhotoUtils5;
|
|
import com.google.gson.Gson;
|
|
|
|
/**
|
|
* @ClassName BillLocationUtils
|
|
* @Author 用户
|
|
* @Date 2022/10/17 10:24
|
|
* @Description TODO
|
|
*/
|
|
public class BillLocationUtils {
|
|
|
|
private Context con;
|
|
|
|
|
|
private static class SingletonHolder {
|
|
private static final BillLocationUtils INSTANCE = new BillLocationUtils();
|
|
}
|
|
|
|
private BillLocationUtils() {
|
|
}
|
|
|
|
public static final BillLocationUtils getInstance() {
|
|
return SingletonHolder.INSTANCE;
|
|
}
|
|
|
|
private HuoYuanRequset hyr;
|
|
private UserRequset ur;
|
|
public void getBillLocation(Context con) {
|
|
this.con = con;
|
|
hyr = new HuoYuanRequset(con, hd);
|
|
ur = new UserRequset(con, hd);
|
|
//获取执行中的运单
|
|
hyr.startOrder(0);
|
|
}
|
|
|
|
public Handler hd = new Handler(msg -> {
|
|
msgMethod(msg);
|
|
return false;
|
|
});
|
|
|
|
public void msgMethod(Message m) {
|
|
switch (m.what) {
|
|
case RequsetCodeConstants.SUCCESS:
|
|
Gson gson = new Gson();
|
|
// Toast.makeText(con,RequsetCodeConstants.FEEDBACK_TEXT,Toast.LENGTH_SHORT).show();
|
|
if (CacheGroup.cacheList.get(HuoYuanFragmengt.START_ORDER) != null) {
|
|
StartOrderBean sob = gson.fromJson(CacheGroup.cacheList.get(HuoYuanFragmengt.START_ORDER), StartOrderBean.class);
|
|
if (sob.getCode() == 200) {
|
|
if (sob.getData() != null) {
|
|
SPUtil.insSP(con, JTTConstant.JTT_DATA_NAME, JTTConstant.JTT_DATA_ORDER_KEY, gson.toJson(sob));
|
|
initStart(sob);
|
|
StartOrderParts.setStartOrder(con, sob);
|
|
ur.getJtts(sob.getData().getShippingNoteNumber());
|
|
}
|
|
} else {
|
|
Toast.makeText(con, sob.getMsg(), Toast.LENGTH_SHORT).show();
|
|
}
|
|
CacheGroup.cacheList.remove(HuoYuanFragmengt.START_ORDER);
|
|
break;
|
|
}
|
|
|
|
if (CacheGroup.cacheList.get("jttRes") != null) {
|
|
JTT jtt = gson.fromJson(CacheGroup.cacheList.get("jttRes"), JTT.class);
|
|
if (jtt.getCode() == 200) {
|
|
SPUtil.insSP(con, "data", "jtt", CacheGroup.cacheList.get("jttRes"));
|
|
JTTProcess.auth(con);
|
|
} else {
|
|
Toast.makeText(con, StringUtil.isNull(jtt.getMsg(), "返回错误"), Toast.LENGTH_LONG).show();
|
|
}
|
|
CacheGroup.cacheList.remove("jttRes");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void initStart(StartOrderBean sob) {
|
|
if (sob.getData() != null) {
|
|
if (sob != null && sob.getData() != null && 0 < sob.getData().getWayChildren().size()) {
|
|
//order_start.setVisibility(View.VISIBLE);
|
|
SPUtil.insSP(con, "order", "ShippingNoteNumber", sob.getData().getShippingNoteNumber());
|
|
Log.e("开始轨迹上传服务", "-----");
|
|
Intent serviceIn = new Intent(con, TrackService.class);
|
|
con.startService(serviceIn);
|
|
} else {
|
|
SPUtil.insSP(con, "order", "ShippingNoteNumber", "");
|
|
}
|
|
}
|
|
}
|
|
}
|