Merge branch 'M9_20221026'

This commit is contained in:
xiaoyan 2022-10-28 16:00:25 +08:00
commit fcb107eb1b
5 changed files with 466 additions and 237 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId "com.navinfo.outdoor"
minSdkVersion 23
targetSdkVersion 30
versionCode 28
versionName "8.221021"
versionCode 29
versionName "8.221028"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {

View File

@ -87,7 +87,6 @@ import com.otaliastudios.cameraview.size.AspectRatio;
import com.otaliastudios.cameraview.size.SizeSelector;
import com.otaliastudios.cameraview.size.SizeSelectors;
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.CameraUpdateFactory;
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
@ -438,14 +437,14 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
}
});
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
Message msg = handler.obtainMessage(0x105);
msg.obj = obtainTecentLocation(latLng);
handler.sendMessage(msg);
}
});
// tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
// @Override
// public void onMapClick(LatLng latLng) {
// Message msg = handler.obtainMessage(0x105);
// msg.obj = obtainTecentLocation(latLng);
// handler.sendMessage(msg);
// }
// });
tencentMap.addTencentMapGestureListener(new TencentMapGestureListener() {
@Override
@ -718,21 +717,21 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
}
// 匹配到终点或匹配距离超过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) {
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
// 匹配到终点后记录该条数据的最新一次匹配距离当下一次匹配距离大于当前距离则认为该数据完全匹配结束匹配
roadMatchEntity.setLastEndDistance(currentEndDistance);
}
} else { // 无法匹配或当前道路并不是距离最近的数据
// 将无法匹配的点位个数记录到对象中
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
// 该数据未匹配但是如果此前已经匹配到结束点则仍然认为匹配成功
if (roadMatchEntity.getEndMathchTime()>0) {
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
} 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 (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数据需要自动生成对应的数据还需要自动复制对应的照片通知服务器采集完成
finishRoadTask(finishEntityMap);
// 语音提示用户
mediaPlayer.start();
systemTTS.playText("拍摄完成");
// 只有在没有正在拍摄的任务所有任务都拍摄完成时才会提示
if (roadMatchEntityList.isEmpty()) {
// 语音提示用户
mediaPlayer.start();
systemTTS.playText("拍摄完成");
}
}
if (!unMatchList.isEmpty()) {
@ -826,7 +828,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
.cls(TaskByNetBean.class)
.params(new HttpParams())
.token(Constant.ACCESS_TOKEN);
okhttp3.Response response = okGoBuilder.getSynchronization();
Response response = okGoBuilder.getSynchronization();
Gson gson = new Gson();
TaskByNetBean taskByNetBean = gson.fromJson(response.body().string(), TaskByNetBean.class);
if (taskByNetBean.getCode() == 200) {
@ -1450,164 +1452,204 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// window.setAttributes(lp);
}
private TencentLocation obtainTecentLocation(LatLng latLng) {
return new TencentLocation() {
@Override
public String getProvider() {
return "NetWork";
}
@Override
public double getLatitude() {
return latLng.getLatitude();
}
@Override
public double getLongitude() {
return latLng.getLongitude();
}
@Override
public double getAltitude() {
return latLng.getAltitude();
}
@Override
public float getAccuracy() {
return 100;
}
@Override
public String getName() {
return "null";
}
@Override
public String getAddress() {
return "null";
}
@Override
public String getNation() {
return "null";
}
@Override
public String getProvince() {
return "null";
}
@Override
public String getCity() {
return "null";
}
@Override
public String getDistrict() {
return "null";
}
@Override
public String getTown() {
return null;
}
@Override
public String getVillage() {
return null;
}
@Override
public String getStreet() {
return null;
}
@Override
public String getStreetNo() {
return null;
}
@Override
public Integer getAreaStat() {
return null;
}
@Override
public List<TencentPoi> getPoiList() {
return null;
}
@Override
public float getBearing() {
return 0;
}
@Override
public float getSpeed() {
return 0;
}
@Override
public long getTime() {
return 0;
}
@Override
public long getElapsedRealtime() {
return 0;
}
@Override
public int getGPSRssi() {
return 0;
}
@Override
public String getIndoorBuildingId() {
return null;
}
@Override
public String getIndoorBuildingFloor() {
return null;
}
@Override
public int getIndoorLocationType() {
return 0;
}
@Override
public double getDirection() {
return 0;
}
@Override
public String getCityCode() {
return null;
}
@Override
public String getCityPhoneCode() {
return null;
}
@Override
public int getCoordinateType() {
return 0;
}
@Override
public int isMockGps() {
return 0;
}
@Override
public Bundle getExtra() {
return null;
}
};
}
// private TencentLocation obtainTecentLocation(LatLng latLng) {
// return new TencentLocation() {
// @Override
// public String getProvider() {
// return "NetWork";
// }
//
// @Override
// public String getFusionProvider() {
// return null;
// }
//
// @Override
// public String getSourceProvider() {
// return null;
// }
//
// @Override
// public double getLatitude() {
// return latLng.getLatitude();
// }
//
// @Override
// public double getLongitude() {
// return latLng.getLongitude();
// }
//
// @Override
// public double getAltitude() {
// return latLng.getAltitude();
// }
//
// @Override
// public float getAccuracy() {
// return 100;
// }
//
// @Override
// public String getName() {
// return "null";
// }
//
// @Override
// public String getAddress() {
// return "null";
// }
//
// @Override
// public String getNation() {
// return "null";
// }
//
// @Override
// public String getProvince() {
// return "null";
// }
//
// @Override
// public String getCity() {
// return "null";
// }
//
// @Override
// public String getDistrict() {
// return "null";
// }
//
// @Override
// public String getTown() {
// return null;
// }
//
// @Override
// public String getVillage() {
// return null;
// }
//
// @Override
// public String getStreet() {
// return null;
// }
//
// @Override
// public String getStreetNo() {
// return null;
// }
//
// @Override
// public Integer getAreaStat() {
// return null;
// }
//
// @Override
// public List<TencentPoi> getPoiList() {
// return null;
// }
//
// @Override
// public float getBearing() {
// return 0;
// }
//
// @Override
// public float getSpeed() {
// return 0;
// }
//
// @Override
// public long getTime() {
// return 0;
// }
//
// @Override
// public long getElapsedRealtime() {
// return 0;
// }
//
// @Override
// public int getGPSRssi() {
// return 0;
// }
//
// @Override
// public int getInOutStatus() {
// return 0;
// }
//
// @Override
// public String getIndoorBuildingId() {
// return null;
// }
//
// @Override
// public String getIndoorBuildingFloor() {
// return null;
// }
//
// @Override
// public int getIndoorLocationType() {
// return 0;
// }
//
// @Override
// public double getDirection() {
// return 0;
// }
//
// @Override
// public String getCityCode() {
// return null;
// }
//
// @Override
// public String getCityPhoneCode() {
// 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() {
@Override

View File

@ -3,8 +3,8 @@ package com.navinfo.outdoor.http;
public class HttpInterface {
// 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 IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String USER_PATH = "/user/";//我的
public static final String MSG_LIST_PATH = "/msgList/";//发现
public static final String USER_LOGIN_PATH = "/userlogin/";//登录

View File

@ -48,6 +48,7 @@ import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.ObservableSource;
import io.reactivex.Observer;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@ -72,22 +73,21 @@ public class DataSaveUtils {
public void onError();
}
// 批量上传文件
public void uploadFiles(Activity mContext, PoiEntity poiEntity, List<File> poiPicList, UploadCallback callback) {
public Single<List<Map.Entry<Integer, File>>> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) {
int auditId = poiEntity.getBodyId();
File zipFile = new File(poiPicList.get(0).getParentFile(), auditId+".zip");
Observable.create(new ObservableOnSubscribe<File>() {
@Override
public void subscribe(ObservableEmitter<File> emitter) throws Exception {
if (!zipFile.exists()) {
// 开始压缩文件
ZipUtil.zipFiles(poiPicList, zipFile, "", null);
}
return Observable.create(new ObservableOnSubscribe<File>() {
@Override
public void subscribe(ObservableEmitter<File> emitter) throws Exception {
if (!zipFile.exists()) {
// 开始压缩文件
ZipUtil.zipFiles(poiPicList, zipFile, "", null);
}
emitter.onNext(zipFile);
emitter.onComplete();
}
})
emitter.onNext(zipFile);
emitter.onComplete();
}
})
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.computation())
// 切分数据发送开始上传请求
@ -169,30 +169,29 @@ public class DataSaveUtils {
public void accept(List<Map.Entry<Integer, File>> entries) throws Exception {
// 最终成功调用finish接口
CommonResponse response = uploadTaskFinish(mContext, auditId);
Message obtain1 = Message.obtain();
obtain1.what = Constant.NEST_WORD_SUBMIT;
if (response.getCode() == 200) { // 更新成功再次更新本地数据库
ToastUtils.Message(mContext, "分包数据上传完成!");
poiEntity.setTaskStatus(100);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
// 提醒用户数据上传完成
obtain1.obj = "数据:" + poiEntity.getName() + " 上传成功";
// 同时删除关联的照片文件和压缩包文件
if (zipFile.exists()) {
zipFile.delete();
}
if (poiPicList!=null&&!poiPicList.isEmpty()) {
for (File picFile: poiPicList
) {
) {
picFile.delete();
}
}
} 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())
.subscribe(new SingleObserver<List<Map.Entry<Integer, File>>>() {
@Override
@ -202,12 +201,23 @@ public class DataSaveUtils {
@Override
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();
}
@Override
public void onError(Throwable e) {
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.onFinish();
}

View File

@ -5,6 +5,7 @@ import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.github.lazylibrary.util.ToastUtils;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
@ -31,7 +32,18 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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;
/*
@ -41,8 +53,9 @@ public class PoiSaveUtils {
private Activity mContext;
private Gson gson;
private static PoiSaveUtils instance;
private int anInt = 0;
private int bInt = 0;
private int anInt = 0; // 上传成功的个数
private int bInt = 0; // 上传失败的个数
private int uploadCount = 0; // 上传的总个数
public static PoiSaveUtils getInstance(Activity mContext) {
if (instance == null) {
@ -60,80 +73,240 @@ public class PoiSaveUtils {
* 批量上传数据到服务端
*/
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
if (poiEntityList != null) {
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) { // 如果是充电站数据首先检查子充电桩的状态
if (poiEntityList != null&&!poiEntityList.isEmpty()) {
// 因为道路任务和POI录像任务需要分包提交因此和其他要素分开分别放在两个管道里
List<PoiEntity> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/
List<PoiEntity> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/
List<PoiEntity> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/
for (PoiEntity poiEntity: poiEntityList) {
if (Constant.submitIdSet.contains(poiEntity.getId())) {
continue;
}
if (poiEntity.getType()==2) {
chargePoiEntityList.add(poiEntity);
} if (poiEntity.getType() == 3 || poiEntity.getType() == 4) {
spliteFilePoiEntityList.add(poiEntity);
} 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()); // 记录全局的正在提交的数据
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 (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 {//其他类型
}
});
// 处理普通数据
Observable otherObserable = Observable.fromIterable(otherPoiEntityList)
.subscribeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) throws Exception {
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);
}
}
}
mContext.runOnUiThread(new Runnable() {
});
// 处理需要分包上传数据的POI录像和道路数据
Observable spliteFileObserable = Observable.fromIterable(spliteFilePoiEntityList)
.subscribeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() {
@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();
obtain.what = Constant.STAY_SUBMIT_ITEM;
obtain.obj = true;
EventBus.getDefault().post(obtain);
if (anInt + bInt > 0) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.NEST_WORD_SUBMIT;
obtain1.obj = "批量提交 成功:" + anInt + ", 失败:" + bInt;
EventBus.getDefault().post(obtain1);
} else {
Message obtain1 = Message.obtain();
obtain1.what = Constant.NEST_WORD_SUBMIT;
obtain1.obj = "批量提交 失败";
EventBus.getDefault().post(obtain1);
}
Message obtain1 = Message.obtain();
obtain1.what = Constant.NEST_WORD_SUBMIT;
obtain1.obj = "批量提交数据,共选中"+uploadCount+"条数据,成功:" + anInt + "条, 失败:" + bInt+"";
EventBus.getDefault().post(obtain1);
Constant.isPresent = true;
}
});
}
}).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;
}
// public interface UploadListener {
// public void uploadCallback();
// }
/**
* 最终上传POI数据到服务
*/