Commit 9ded4d4a by 罗翻

增加定位上传接口

parent 6fa1806d
......@@ -63,5 +63,14 @@ public interface APIService {
*/
@GET(Constants.MESSAGE_NUM)
Observable<BaseResponse<Integer>> getHxNum(@Path("hxAccount") String hxAccount);
/**
* 上传地理位置.
* @param body
* @return
*/
@POST(Constants.COMMITE_LOCAITON)
Observable<BaseResponse<Boolean>> commiteLocation(@Body RequestBody body);
}
......@@ -34,4 +34,8 @@ public class ApiFactory {
return Api.getService(APIService.class).getHxNum(hxAccount).compose(Api.applySchedulers());
}
public static Observable<Boolean> commiteLocation(RequestBody requestBody) {
return Api.getService(APIService.class).commiteLocation(requestBody).compose(Api.applySchedulers());
}
}
......@@ -30,6 +30,7 @@ import com.dayu.bigfish.ui.fragment.HomeFirstTabFragment;
import com.dayu.bigfish.ui.service.LocationService;
import com.dayu.common.Constants;
import com.dayu.event.DownloadBean;
import com.dayu.event.UserInfo;
import com.dayu.location.base.LocationUtils;
import com.dayu.message.ui.fragment.HomeMessageFragment;
import com.dayu.order.ui.activity.ReceivingActivity;
......@@ -42,6 +43,7 @@ import com.dayu.utils.UserManager;
import com.dayu.utils.badgeNumberManger.BadgeNumberManager;
import com.dayu.widgets.CustomDialog;
import com.dayu.widgets.listener.onDownloadListener;
import com.megvii.idcardlib.util.Constant;
import com.umeng.analytics.MobclickAgent;
import org.greenrobot.eventbus.EventBus;
......@@ -235,8 +237,10 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
@Override
public void startLocaitonService() {
UserInfo userInfo = UserManager.getInstance().getUser();
Intent intent = new Intent(mActivity, LocationService.class);
intent.putExtra(Constants.ID, UserManager.getInstance().getUser().getAccountId());
intent.putExtra(Constants.ACCOUNT_ID, userInfo.getAccountId());
intent.putExtra(Constants.ID, userInfo.getSiteId());
mActivity.startService(intent);
}
......
......@@ -8,13 +8,20 @@ import android.os.IBinder;
import android.os.Message;
import android.support.annotation.Nullable;
import com.dayu.bigfish.api.ApiFactory;
import com.dayu.common.Constants;
import com.dayu.location.base.LocationUtils;
import com.dayu.utils.LogUtils;
import com.dayu.utils.ToastUtils;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Timer;
import java.util.TimerTask;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* Created by luofan
* on 2018/7/17.
......@@ -24,6 +31,8 @@ public class LocationService extends Service {
private final Timer mTimer = new Timer();
private TimerTask mTask;
private Handler mHandler;
private int mAccountId;
private int mSiteId;
@SuppressLint("HandlerLeak")
@Override
......@@ -32,9 +41,22 @@ public class LocationService extends Service {
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (mAccountId == 0 || mSiteId == 0) {
return;
}
mHandler.post(() -> LocationUtils.getCurrentLocation(location -> {
if (location != null) {
LogUtils.d("locationService", location.getCity());
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("accountId", mAccountId);
jsonObject.put("siteId", mSiteId);
jsonObject.put("longitude", location.getLongitude());
jsonObject.put("latitude", location.getLatitude());
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
ApiFactory.commiteLocation(requestBody).subscribe(aBoolean -> ToastUtils.showShortToast("地址上传成功"));
}
}));
super.handleMessage(msg);
......@@ -59,7 +81,14 @@ public class LocationService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
String id = intent.getStringExtra(Constants.ID);
String accounid = intent.getStringExtra(Constants.ACCOUNT_ID);
String siteID = intent.getStringExtra(Constants.ID);
if (accounid != null) {
mAccountId = Integer.parseInt(accounid);
}
if (siteID != null) {
mSiteId = Integer.parseInt(siteID);
}
}
sendMessage();
return super.onStartCommand(intent, flags, startId);
......
......@@ -12,16 +12,16 @@ public class Constants {
/**
* 测试环境配置.
*/
// public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static final String ENVIROMENT = "debug";
// public static final String BASE_URL = "http://47.94.101.239:3112";
// public final static String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply";
// public final static String WEB_SOP = "http://47.94.101.239:9004/#/sop";
// public final static String CHECK_MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manyServiceResult";
// public final static String MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manySop";
// public final static String WEB_SOP_DETAIL = "http://47.94.101.239:9004/#/sopdetail";
// public final static String WEB_ZHI_SHI = "http://47.94.101.239:9004/#/detail";
// public static final boolean IS_DEBUG = true;
public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
public static final String ENVIROMENT = "debug";
public static final String BASE_URL = "http://47.94.101.239:3112";
public final static String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply";
public final static String WEB_SOP = "http://47.94.101.239:9004/#/sop";
public final static String CHECK_MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manyServiceResult";
public final static String MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manySop";
public final static String WEB_SOP_DETAIL = "http://47.94.101.239:9004/#/sopdetail";
public final static String WEB_ZHI_SHI = "http://47.94.101.239:9004/#/detail";
public static final boolean IS_DEBUG = true;
/**
* uat环境配置.
......@@ -40,16 +40,16 @@ public class Constants {
/**
* 正式环境.
*/
public static final String ENVIROMENT = "release";
public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
public static final String BASE_URL = "https://mobile.kf.ai";
public final static String UP_PHOTO = "/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply";
public final static String WEB_SOP = "https://sop.kf.ai/#/sop";
public final static String WEB_SOP_DETAIL = "https://sop.kf.ai/#/sopdetail";
public final static String WEB_ZHI_SHI = "https://sop.kf.ai/#/detail";
public final static String CHECK_MULTI_WEB_SOP = "https://sop.kf.ai/#/manyServiceResult";
public final static String MULTI_WEB_SOP = "https://sop.kf.ai/#/manySop";
public static final boolean IS_DEBUG = false;
// public static final String ENVIROMENT = "release";
// public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static final String BASE_URL = "https://mobile.kf.ai";
// public final static String UP_PHOTO = "/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply";
// public final static String WEB_SOP = "https://sop.kf.ai/#/sop";
// public final static String WEB_SOP_DETAIL = "https://sop.kf.ai/#/sopdetail";
// public final static String WEB_ZHI_SHI = "https://sop.kf.ai/#/detail";
// public final static String CHECK_MULTI_WEB_SOP = "https://sop.kf.ai/#/manyServiceResult";
// public final static String MULTI_WEB_SOP = "https://sop.kf.ai/#/manySop";
// public static final boolean IS_DEBUG = false;
/**
* 演示环境
......@@ -94,6 +94,11 @@ public class Constants {
*/
public final static String MESSAGE_NUM = " /api-message/" + "hXMessage/count/hxAccount/{hxAccount}";
/**
* 上传地理位置.
*/
public final static String COMMITE_LOCAITON = " /api-user/" + "/engineerPathParticle";
/***********************其他配置**********************************/
public final static int PAGESIZE = 20;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment