Merge branch 'M9_20221026'
This commit is contained in:
commit
fcb107eb1b
@ -12,8 +12,8 @@ android {
|
|||||||
applicationId "com.navinfo.outdoor"
|
applicationId "com.navinfo.outdoor"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 28
|
versionCode 29
|
||||||
versionName "8.221021"
|
versionName "8.221028"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
|
@ -87,7 +87,6 @@ import com.otaliastudios.cameraview.size.AspectRatio;
|
|||||||
import com.otaliastudios.cameraview.size.SizeSelector;
|
import com.otaliastudios.cameraview.size.SizeSelector;
|
||||||
import com.otaliastudios.cameraview.size.SizeSelectors;
|
import com.otaliastudios.cameraview.size.SizeSelectors;
|
||||||
import com.tencent.map.geolocation.TencentLocation;
|
import com.tencent.map.geolocation.TencentLocation;
|
||||||
import com.tencent.map.geolocation.TencentPoi;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||||
@ -438,14 +437,14 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
|
// tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onMapClick(LatLng latLng) {
|
// public void onMapClick(LatLng latLng) {
|
||||||
Message msg = handler.obtainMessage(0x105);
|
// Message msg = handler.obtainMessage(0x105);
|
||||||
msg.obj = obtainTecentLocation(latLng);
|
// msg.obj = obtainTecentLocation(latLng);
|
||||||
handler.sendMessage(msg);
|
// handler.sendMessage(msg);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
tencentMap.addTencentMapGestureListener(new TencentMapGestureListener() {
|
tencentMap.addTencentMapGestureListener(new TencentMapGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -718,21 +717,21 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
|||||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||||
}
|
}
|
||||||
// 匹配到终点、或匹配距离超过90%
|
// 匹配到终点、或匹配距离超过90%
|
||||||
if (roadMatchEntity.getMatchPointList().size()>=2&&GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER
|
if ((roadMatchEntity.getMatchPointList().size()>=2&&GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER)
|
||||||
|| currentEndDistance<= finalMatchStartDistance) {
|
|| currentEndDistance<= finalMatchStartDistance) {
|
||||||
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
||||||
// 匹配到终点后,记录该条数据的最新一次匹配距离,当下一次匹配距离大于当前距离,则认为该数据完全匹配,结束匹配
|
// 匹配到终点后,记录该条数据的最新一次匹配距离,当下一次匹配距离大于当前距离,则认为该数据完全匹配,结束匹配
|
||||||
roadMatchEntity.setLastEndDistance(currentEndDistance);
|
roadMatchEntity.setLastEndDistance(currentEndDistance);
|
||||||
}
|
}
|
||||||
} else { // 无法匹配,或当前道路并不是距离最近的数据
|
} else { // 无法匹配,或当前道路并不是距离最近的数据
|
||||||
|
// 将无法匹配的点位个数记录到对象中
|
||||||
|
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
|
||||||
|
roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0
|
||||||
|
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||||
// 该数据未匹配,但是如果此前已经匹配到结束点,则仍然认为匹配成功
|
// 该数据未匹配,但是如果此前已经匹配到结束点,则仍然认为匹配成功
|
||||||
if (roadMatchEntity.getEndMathchTime()>0) {
|
if (roadMatchEntity.getEndMathchTime()>0) {
|
||||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||||
} else {
|
} else {
|
||||||
// 将无法匹配的点位个数记录到对象中
|
|
||||||
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
|
|
||||||
roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0
|
|
||||||
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
|
||||||
// 判断当前是否存在已匹配的点
|
// 判断当前是否存在已匹配的点
|
||||||
if (roadMatchEntity.getMatchPointList().size()>1) { // 存在匹配的点超过1个,根据长度判断
|
if (roadMatchEntity.getMatchPointList().size()>1) { // 存在匹配的点超过1个,根据长度判断
|
||||||
if (GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>UNMATCH_GIVE_UP_DISTANCE_BUFFER) {
|
if (GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>UNMATCH_GIVE_UP_DISTANCE_BUFFER) {
|
||||||
@ -770,9 +769,12 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
|||||||
}
|
}
|
||||||
// TODO 完成的entity数据,需要自动生成对应的数据,还需要自动复制对应的照片,通知服务器采集完成
|
// TODO 完成的entity数据,需要自动生成对应的数据,还需要自动复制对应的照片,通知服务器采集完成
|
||||||
finishRoadTask(finishEntityMap);
|
finishRoadTask(finishEntityMap);
|
||||||
// 语音提示用户
|
// 只有在没有正在拍摄的任务,所有任务都拍摄完成时才会提示
|
||||||
mediaPlayer.start();
|
if (roadMatchEntityList.isEmpty()) {
|
||||||
systemTTS.playText("拍摄完成");
|
// 语音提示用户
|
||||||
|
mediaPlayer.start();
|
||||||
|
systemTTS.playText("拍摄完成");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unMatchList.isEmpty()) {
|
if (!unMatchList.isEmpty()) {
|
||||||
@ -826,7 +828,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
|||||||
.cls(TaskByNetBean.class)
|
.cls(TaskByNetBean.class)
|
||||||
.params(new HttpParams())
|
.params(new HttpParams())
|
||||||
.token(Constant.ACCESS_TOKEN);
|
.token(Constant.ACCESS_TOKEN);
|
||||||
okhttp3.Response response = okGoBuilder.getSynchronization();
|
Response response = okGoBuilder.getSynchronization();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
TaskByNetBean taskByNetBean = gson.fromJson(response.body().string(), TaskByNetBean.class);
|
TaskByNetBean taskByNetBean = gson.fromJson(response.body().string(), TaskByNetBean.class);
|
||||||
if (taskByNetBean.getCode() == 200) {
|
if (taskByNetBean.getCode() == 200) {
|
||||||
@ -1450,164 +1452,204 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
|||||||
// window.setAttributes(lp);
|
// window.setAttributes(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TencentLocation obtainTecentLocation(LatLng latLng) {
|
// private TencentLocation obtainTecentLocation(LatLng latLng) {
|
||||||
return new TencentLocation() {
|
// return new TencentLocation() {
|
||||||
@Override
|
// @Override
|
||||||
public String getProvider() {
|
// public String getProvider() {
|
||||||
return "NetWork";
|
// return "NetWork";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public double getLatitude() {
|
// public String getFusionProvider() {
|
||||||
return latLng.getLatitude();
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public double getLongitude() {
|
// public String getSourceProvider() {
|
||||||
return latLng.getLongitude();
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public double getAltitude() {
|
// public double getLatitude() {
|
||||||
return latLng.getAltitude();
|
// return latLng.getLatitude();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public float getAccuracy() {
|
// public double getLongitude() {
|
||||||
return 100;
|
// return latLng.getLongitude();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getName() {
|
// public double getAltitude() {
|
||||||
return "null";
|
// return latLng.getAltitude();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getAddress() {
|
// public float getAccuracy() {
|
||||||
return "null";
|
// return 100;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getNation() {
|
// public String getName() {
|
||||||
return "null";
|
// return "null";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getProvince() {
|
// public String getAddress() {
|
||||||
return "null";
|
// return "null";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getCity() {
|
// public String getNation() {
|
||||||
return "null";
|
// return "null";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getDistrict() {
|
// public String getProvince() {
|
||||||
return "null";
|
// return "null";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getTown() {
|
// public String getCity() {
|
||||||
return null;
|
// return "null";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getVillage() {
|
// public String getDistrict() {
|
||||||
return null;
|
// return "null";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getStreet() {
|
// public String getTown() {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getStreetNo() {
|
// public String getVillage() {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Integer getAreaStat() {
|
// public String getStreet() {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<TencentPoi> getPoiList() {
|
// public String getStreetNo() {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public float getBearing() {
|
// public Integer getAreaStat() {
|
||||||
return 0;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public float getSpeed() {
|
// public List<TencentPoi> getPoiList() {
|
||||||
return 0;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public long getTime() {
|
// public float getBearing() {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public long getElapsedRealtime() {
|
// public float getSpeed() {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int getGPSRssi() {
|
// public long getTime() {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getIndoorBuildingId() {
|
// public long getElapsedRealtime() {
|
||||||
return null;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getIndoorBuildingFloor() {
|
// public int getGPSRssi() {
|
||||||
return null;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int getIndoorLocationType() {
|
// public int getInOutStatus() {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public double getDirection() {
|
// public String getIndoorBuildingId() {
|
||||||
return 0;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getCityCode() {
|
// public String getIndoorBuildingFloor() {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getCityPhoneCode() {
|
// public int getIndoorLocationType() {
|
||||||
return null;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int getCoordinateType() {
|
// public double getDirection() {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int isMockGps() {
|
// public String getCityCode() {
|
||||||
return 0;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Bundle getExtra() {
|
// public String getCityPhoneCode() {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
};
|
//
|
||||||
}
|
// @Override
|
||||||
|
// public TencentMotion getMotion() {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int getGpsQuality() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public float getDeltaAngle() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public float getDeltaSpeed() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int getCoordinateType() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int getFakeReason() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int isMockGps() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Bundle getExtra() {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
private Handler handler = new Handler(new Handler.Callback() {
|
private Handler handler = new Handler(new Handler.Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,8 +3,8 @@ package com.navinfo.outdoor.http;
|
|||||||
public class HttpInterface {
|
public class HttpInterface {
|
||||||
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP
|
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP
|
||||||
public static final String IPm = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
|
public static final String IPm = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
|
||||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
|
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
|
||||||
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
||||||
public static final String USER_PATH = "/user/";//我的
|
public static final String USER_PATH = "/user/";//我的
|
||||||
public static final String MSG_LIST_PATH = "/msgList/";//发现
|
public static final String MSG_LIST_PATH = "/msgList/";//发现
|
||||||
public static final String USER_LOGIN_PATH = "/userlogin/";//登录
|
public static final String USER_LOGIN_PATH = "/userlogin/";//登录
|
||||||
|
@ -48,6 +48,7 @@ import io.reactivex.ObservableEmitter;
|
|||||||
import io.reactivex.ObservableOnSubscribe;
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
import io.reactivex.ObservableSource;
|
import io.reactivex.ObservableSource;
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
|
import io.reactivex.Single;
|
||||||
import io.reactivex.SingleObserver;
|
import io.reactivex.SingleObserver;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
@ -72,22 +73,21 @@ public class DataSaveUtils {
|
|||||||
public void onError();
|
public void onError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量上传文件
|
public Single<List<Map.Entry<Integer, File>>> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) {
|
||||||
public void uploadFiles(Activity mContext, PoiEntity poiEntity, List<File> poiPicList, UploadCallback callback) {
|
|
||||||
int auditId = poiEntity.getBodyId();
|
int auditId = poiEntity.getBodyId();
|
||||||
File zipFile = new File(poiPicList.get(0).getParentFile(), auditId+".zip");
|
File zipFile = new File(poiPicList.get(0).getParentFile(), auditId+".zip");
|
||||||
Observable.create(new ObservableOnSubscribe<File>() {
|
return Observable.create(new ObservableOnSubscribe<File>() {
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(ObservableEmitter<File> emitter) throws Exception {
|
public void subscribe(ObservableEmitter<File> emitter) throws Exception {
|
||||||
if (!zipFile.exists()) {
|
if (!zipFile.exists()) {
|
||||||
// 开始压缩文件
|
// 开始压缩文件
|
||||||
ZipUtil.zipFiles(poiPicList, zipFile, "", null);
|
ZipUtil.zipFiles(poiPicList, zipFile, "", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.onNext(zipFile);
|
emitter.onNext(zipFile);
|
||||||
emitter.onComplete();
|
emitter.onComplete();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.computation())
|
.observeOn(Schedulers.computation())
|
||||||
// 切分数据,发送开始上传请求
|
// 切分数据,发送开始上传请求
|
||||||
@ -169,30 +169,29 @@ public class DataSaveUtils {
|
|||||||
public void accept(List<Map.Entry<Integer, File>> entries) throws Exception {
|
public void accept(List<Map.Entry<Integer, File>> entries) throws Exception {
|
||||||
// 最终成功,调用finish接口
|
// 最终成功,调用finish接口
|
||||||
CommonResponse response = uploadTaskFinish(mContext, auditId);
|
CommonResponse response = uploadTaskFinish(mContext, auditId);
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
|
||||||
if (response.getCode() == 200) { // 更新成功,再次更新本地数据库
|
if (response.getCode() == 200) { // 更新成功,再次更新本地数据库
|
||||||
ToastUtils.Message(mContext, "分包数据上传完成!");
|
|
||||||
poiEntity.setTaskStatus(100);
|
poiEntity.setTaskStatus(100);
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
// 提醒用户数据上传完成
|
|
||||||
obtain1.obj = "数据:" + poiEntity.getName() + " 上传成功";
|
|
||||||
// 同时删除关联的照片文件和压缩包文件
|
// 同时删除关联的照片文件和压缩包文件
|
||||||
if (zipFile.exists()) {
|
if (zipFile.exists()) {
|
||||||
zipFile.delete();
|
zipFile.delete();
|
||||||
}
|
}
|
||||||
if (poiPicList!=null&&!poiPicList.isEmpty()) {
|
if (poiPicList!=null&&!poiPicList.isEmpty()) {
|
||||||
for (File picFile: poiPicList
|
for (File picFile: poiPicList
|
||||||
) {
|
) {
|
||||||
picFile.delete();
|
picFile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obtain1.obj = "数据:" + poiEntity.getName() + " 上传失败";
|
throw new Exception("数据:" + poiEntity.getName() + " 上传失败");
|
||||||
}
|
}
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量上传文件
|
||||||
|
public void uploadFiles(Activity mContext, PoiEntity poiEntity, List<File> poiPicList, UploadCallback callback) {
|
||||||
|
getUploadSpliteFilesObservble(mContext, poiEntity, poiPicList)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new SingleObserver<List<Map.Entry<Integer, File>>>() {
|
.subscribe(new SingleObserver<List<Map.Entry<Integer, File>>>() {
|
||||||
@Override
|
@Override
|
||||||
@ -202,12 +201,23 @@ public class DataSaveUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Map.Entry<Integer, File>> entries) {
|
public void onSuccess(List<Map.Entry<Integer, File>> entries) {
|
||||||
|
ToastUtils.Message(mContext, "分包数据上传完成!");
|
||||||
|
Message obtain1 = Message.obtain();
|
||||||
|
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||||
|
// 提醒用户数据上传完成
|
||||||
|
obtain1.obj = "数据:" + poiEntity.getName() + " 上传成功";
|
||||||
|
EventBus.getDefault().post(obtain1);
|
||||||
callback.onFinish();
|
callback.onFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
ToastUtils.Message(mContext, e.getMessage());
|
ToastUtils.Message(mContext, e.getMessage());
|
||||||
|
Message obtain1 = Message.obtain();
|
||||||
|
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||||
|
// 提醒用户数据上传完成
|
||||||
|
obtain1.obj = e.getMessage();
|
||||||
|
EventBus.getDefault().post(obtain1);
|
||||||
callback.onError();
|
callback.onError();
|
||||||
callback.onFinish();
|
callback.onFinish();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.os.Message;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.github.lazylibrary.util.ToastUtils;
|
||||||
import com.github.lazylibrary.util.ZipUtil;
|
import com.github.lazylibrary.util.ZipUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
@ -31,7 +32,18 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.ObservableSource;
|
||||||
|
import io.reactivex.Observer;
|
||||||
|
import io.reactivex.Single;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
import io.reactivex.functions.Consumer;
|
||||||
|
import io.reactivex.functions.Function;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -41,8 +53,9 @@ public class PoiSaveUtils {
|
|||||||
private Activity mContext;
|
private Activity mContext;
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
private static PoiSaveUtils instance;
|
private static PoiSaveUtils instance;
|
||||||
private int anInt = 0;
|
private int anInt = 0; // 上传成功的个数
|
||||||
private int bInt = 0;
|
private int bInt = 0; // 上传失败的个数
|
||||||
|
private int uploadCount = 0; // 上传的总个数
|
||||||
|
|
||||||
public static PoiSaveUtils getInstance(Activity mContext) {
|
public static PoiSaveUtils getInstance(Activity mContext) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
@ -60,80 +73,240 @@ public class PoiSaveUtils {
|
|||||||
* 批量上传数据到服务端
|
* 批量上传数据到服务端
|
||||||
*/
|
*/
|
||||||
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
|
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
|
||||||
if (poiEntityList != null) {
|
if (poiEntityList != null&&!poiEntityList.isEmpty()) {
|
||||||
new Thread(new Runnable() {
|
// 因为道路任务和POI录像任务需要分包提交,因此和其他要素分开,分别放在两个管道里
|
||||||
@Override
|
List<PoiEntity> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||||
public void run() {
|
List<PoiEntity> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||||
anInt = 0;
|
List<PoiEntity> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||||
bInt = 0;
|
for (PoiEntity poiEntity: poiEntityList) {
|
||||||
Log.d("PoiSaveUtils", "开始上传");
|
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
||||||
for (int i = 0; i < poiEntityList.size(); i++) {
|
continue;
|
||||||
PoiEntity poiEntity = poiEntityList.get(i);
|
}
|
||||||
Log.d("PoiSaveUtils", "poiEntity.getType():"+poiEntity.getType());
|
if (poiEntity.getType()==2) {
|
||||||
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
chargePoiEntityList.add(poiEntity);
|
||||||
continue;
|
} if (poiEntity.getType() == 3 || poiEntity.getType() == 4) {
|
||||||
}
|
spliteFilePoiEntityList.add(poiEntity);
|
||||||
if (poiEntity.getType() == 2) { // 如果是充电站数据,首先检查子充电桩的状态
|
} else {
|
||||||
|
otherPoiEntityList.add(poiEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Observable chargePoiObserable = Observable.fromIterable(chargePoiEntityList)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.doOnNext(new Consumer<PoiEntity>() {
|
||||||
|
@Override
|
||||||
|
public void accept(PoiEntity poiEntity) throws Exception {
|
||||||
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
||||||
if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
|
if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
||||||
|
Constant.submitIdSet.remove(poiEntity.getId());
|
||||||
|
}
|
||||||
if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
||||||
// 开始上传流程
|
// 开始上传流程
|
||||||
if (saveChargingPileUploadChargingStation(poiEntity)) {
|
if (saveChargingPileUploadChargingStation(poiEntity)) {
|
||||||
uploadPoiNet(poiEntity);
|
uploadPoiNet(poiEntity);
|
||||||
}else {
|
}else {
|
||||||
|
bInt++;
|
||||||
poiEntity.setChecked(false);
|
poiEntity.setChecked(false);
|
||||||
poiEntity.setWork_type(0);
|
poiEntity.setWork_type(0);
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
bInt++;
|
||||||
poiEntity.setChecked(false);
|
poiEntity.setChecked(false);
|
||||||
poiEntity.setWork_type(0);
|
poiEntity.setWork_type(0);
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
bInt++;
|
||||||
poiEntity.setChecked(false);
|
poiEntity.setChecked(false);
|
||||||
poiEntity.setWork_type(0);
|
poiEntity.setWork_type(0);
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
Constant.submitIdSet.remove(poiEntity.getId());
|
||||||
|
sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
}
|
}
|
||||||
} else {//其他类型
|
}
|
||||||
|
});
|
||||||
|
// 处理普通数据
|
||||||
|
Observable otherObserable = Observable.fromIterable(otherPoiEntityList)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.doOnNext(new Consumer<PoiEntity>() {
|
||||||
|
@Override
|
||||||
|
public void accept(PoiEntity poiEntity) throws Exception {
|
||||||
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||||
//走上传流程:
|
//走上传流程:
|
||||||
uploadPoiNet(poiEntity);
|
uploadPoiNet(poiEntity);
|
||||||
}else {
|
}else {
|
||||||
|
bInt++;
|
||||||
poiEntity.setChecked(false);
|
poiEntity.setChecked(false);
|
||||||
poiEntity.setWork_type(0);
|
poiEntity.setWork_type(0);
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
mContext.runOnUiThread(new Runnable() {
|
// 处理需要分包上传数据的POI录像和道路数据
|
||||||
|
Observable spliteFileObserable = Observable.fromIterable(spliteFilePoiEntityList)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.doOnNext(new Consumer<PoiEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void accept(PoiEntity poiEntity) throws Exception {
|
||||||
|
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||||
|
//走上传流程:
|
||||||
|
if (poiEntity == null) {
|
||||||
|
bInt++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int bodyId = poiEntity.getBodyId();
|
||||||
|
if (bodyId == 0) {
|
||||||
|
bInt++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
bInt++;
|
||||||
|
poiEntity.setChecked(false);
|
||||||
|
poiEntity.setWork_type(0);
|
||||||
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.concatMap(new Function<PoiEntity, ObservableSource<?>>() {
|
||||||
|
@Override
|
||||||
|
public ObservableSource<?> apply(PoiEntity poiEntity) throws Exception {
|
||||||
|
List<File> photoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
||||||
|
return DataSaveUtils.getInstance().getUploadSpliteFilesObservble(mContext, poiEntity, photoFileList)
|
||||||
|
.toObservable();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.doOnNext(new Consumer<Object>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Object o) throws Exception {
|
||||||
|
anInt++;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.doOnError(new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
bInt++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Observable.concat(
|
||||||
|
otherObserable, spliteFileObserable, chargePoiObserable
|
||||||
|
).subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
anInt = 0;
|
||||||
|
bInt = 0;
|
||||||
|
uploadCount = chargePoiEntityList.size()+spliteFilePoiEntityList.size()+otherPoiEntityList.size();
|
||||||
|
Log.d("PoiSaveUtils", "开始上传");
|
||||||
|
ToastUtils.showToast(mContext, "开始批量上传数据,本次共需上传"+uploadCount+"条数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(Object o) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
ToastUtils.showToast(mContext, e.getMessage());
|
||||||
|
Constant.isPresent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||||
obtain.obj = true;
|
obtain.obj = true;
|
||||||
EventBus.getDefault().post(obtain);
|
EventBus.getDefault().post(obtain);
|
||||||
if (anInt + bInt > 0) {
|
Message obtain1 = Message.obtain();
|
||||||
Message obtain1 = Message.obtain();
|
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
obtain1.obj = "批量提交数据,共选中"+uploadCount+"条数据,成功:" + anInt + "条, 失败:" + bInt+"条";
|
||||||
obtain1.obj = "批量提交 成功:" + anInt + ", 失败:" + bInt;
|
EventBus.getDefault().post(obtain1);
|
||||||
EventBus.getDefault().post(obtain1);
|
Constant.isPresent = true;
|
||||||
} else {
|
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
|
||||||
obtain1.obj = "批量提交 失败";
|
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
|
// new Thread(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// anInt = 0;
|
||||||
|
// bInt = 0;
|
||||||
|
// Log.d("PoiSaveUtils", "开始上传");
|
||||||
|
// for (int i = 0; i < poiEntityList.size(); i++) {
|
||||||
|
// PoiEntity poiEntity = poiEntityList.get(i);
|
||||||
|
// Log.d("PoiSaveUtils", "poiEntity.getType():"+poiEntity.getType());
|
||||||
|
// if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// if (poiEntity.getType() == 2) { // 如果是充电站数据,首先检查子充电桩的状态
|
||||||
|
// Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
||||||
|
// if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
|
||||||
|
// Constant.submitIdSet.remove(poiEntity.getId());
|
||||||
|
// if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
||||||
|
// // 开始上传流程
|
||||||
|
// if (saveChargingPileUploadChargingStation(poiEntity)) {
|
||||||
|
// uploadPoiNet(poiEntity);
|
||||||
|
// }else {
|
||||||
|
// bInt++;
|
||||||
|
// poiEntity.setChecked(false);
|
||||||
|
// poiEntity.setWork_type(0);
|
||||||
|
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// bInt++;
|
||||||
|
// poiEntity.setChecked(false);
|
||||||
|
// poiEntity.setWork_type(0);
|
||||||
|
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// bInt++;
|
||||||
|
// poiEntity.setChecked(false);
|
||||||
|
// poiEntity.setWork_type(0);
|
||||||
|
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
// Constant.submitIdSet.remove(poiEntity.getId());
|
||||||
|
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
|
// }
|
||||||
|
// } else {//其他类型
|
||||||
|
// if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||||
|
// //走上传流程:
|
||||||
|
// uploadPoiNet(poiEntity);
|
||||||
|
// }else {
|
||||||
|
// bInt++;
|
||||||
|
// poiEntity.setChecked(false);
|
||||||
|
// poiEntity.setWork_type(0);
|
||||||
|
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendUploadMessage(int count, int success, int fail) {
|
||||||
|
if (success+fail == count) { // 成功和失败的个数与数据总数相同
|
||||||
|
Message obtain = Message.obtain();
|
||||||
|
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||||
|
obtain.obj = true;
|
||||||
|
EventBus.getDefault().post(obtain);
|
||||||
|
}
|
||||||
|
Message obtain1 = Message.obtain();
|
||||||
|
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||||
|
obtain1.obj = "批量提交数据,共选中"+count+"条数据,成功:" + anInt + "条, 失败:" + bInt+"条";
|
||||||
|
EventBus.getDefault().post(obtain1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 保存数据到服务
|
* 保存数据到服务
|
||||||
*/
|
*/
|
||||||
@ -221,6 +394,10 @@ public class PoiSaveUtils {
|
|||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public interface UploadListener {
|
||||||
|
// public void uploadCallback();
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最终上传POI数据到服务
|
* 最终上传POI数据到服务
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user